Skip to content

Commit f6584bc

Browse files
authoredOct 17, 2024
mention ridlfmt and add it to example (webrpc#321)
1 parent 4ee0d88 commit f6584bc

File tree

5 files changed

+34
-36
lines changed

5 files changed

+34
-36
lines changed
 

‎README.md

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ simplifying the development of backend services for modern Web applications.
2020
- [Development](#development)
2121
- [Building from source](#building-from-source)
2222
- [Writing your own code-generator](#writing-your-own-code-generator)
23+
- [Format ridl files](#format-ridl)
2324
- [Authors](#authors)
2425
- [Credits](#credits)
2526
- [License](#license)
@@ -214,6 +215,10 @@ For more information please see the [schema readme](./schema/README.md).
214215

215216
See [webrpc-gen documentation](./gen).
216217

218+
## Format ridl
219+
- Use [Ridlfmt](https://github.com/webrpc/ridlfmt)
220+
- Supports same arguments as `gofmt`
221+
- See: [Example](https://github.com/webrpc/webrpc/blob/master/_examples/golang-basics/Makefile#L4)
217222

218223
# Authors
219224

‎_examples/golang-basics/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
all:
22
@awk -F'[ :]' '!/^all:/ && /^([A-z_-]+):/ {print "make " $$1}' Makefile
33

4+
format:
5+
go run github.com/webrpc/ridlfmt@v0.2.0 -w example.ridl
6+
47
generate:
58
webrpc-gen -schema=example.ridl -target=golang -pkg=main -server -client -service="ExampleService" -out=./example.gen.go
69
webrpc-gen -schema=example.ridl -target=golang -pkg=admin -server -client -service="AdminService" -ignore="@deprecated" -out=./admin/admin.gen.go

‎_examples/golang-basics/example.ridl

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
webrpc = v1 # version of webrpc schema format (ridl or json)
1+
webrpc = v1 # version of webrpc schema format (ridl or json)
22

3-
name = example # name of your backend app
4-
version = v0.0.1 # version of your schema
5-
3+
name = example # name of your backend app
4+
version = v0.0.1 # version of your schema
65

76
enum Kind: uint32
87
- USER
@@ -56,43 +55,41 @@ struct ComplexType
5655
- mapOfUsers: map<string,User>
5756
- user: User
5857

59-
60-
error 1000 UserNotFound "User not found" HTTP 404
61-
error 2000 Unauthorized "Unauthorized access" HTTP 401
62-
error 3000 PermissionDenied "Permission denied" HTTP 403
63-
58+
error 1000 UserNotFound "User not found" HTTP 404
59+
error 2000 Unauthorized "Unauthorized access" HTTP 401
60+
error 3000 PermissionDenied "Permission denied" HTTP 403
6461

6562
service ExampleService
66-
@internal
63+
@internal
6764
- Ping()
68-
@internal
65+
@internal
6966
- Status() => (status: bool)
70-
@internal
67+
@internal
7168
- Version() => (version: Version)
72-
@deprecated:GetUserV2
73-
@internal
69+
@deprecated:GetUserV2
70+
@internal
7471
- GetUser(header: map<string,string>, userID: uint64) => (code: uint32, user: User)
75-
@public
76-
@auth:"X-Access-Key,S2S,Cookies"
72+
@public
73+
@auth:"X-Access-Key,S2S,Cookies"
7774
- GetUserV2(header: map<string,string>, userID: uint64) => (code: uint32, user: User, profile: string)
78-
@public
75+
@public
7976
- FindUser(s: SearchFilter) => (name: string, user: User)
80-
@public
77+
@public
8178
- GetIntents() => (intents: []Intent)
82-
@public
79+
@public
8380
- CountIntents(userId: uint64) => (count: map<Intent,uint32>)
8481

8582
service ExampleServiceV2
8683
- Ping()
8784
- Status() => (status: bool)
8885

8986
service AdminService
90-
@public
91-
@deprecated:Auth
87+
@public
88+
@deprecated:Auth
9289
- AuthOld() => (jwt: string)
93-
@public
90+
@public
9491
- Auth() => (jwt: string, role: string)
95-
@internal
92+
@internal
9693
- Status() => (status: bool)
97-
@internal
98-
- Version() => (version: Version)
94+
@internal
95+
- Version() => (version: Version)

‎_examples/golang-basics/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module github.com/webrpc/webrpc/_example/golang-basics
22

3-
go 1.19
3+
go 1.22
44

55
require (
66
github.com/go-chi/chi/v5 v5.0.12
7-
github.com/stretchr/testify v1.8.1
7+
github.com/stretchr/testify v1.9.0
88
)
99

1010
require (

‎_examples/golang-basics/go.sum

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
21
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
32
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
43
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
54
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
65
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
76
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
9-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
10-
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
11-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
12-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
13-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
14-
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
7+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
8+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
159
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1610
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
17-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1811
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1912
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)
Please sign in to comment.