Closed duckjiangwei closed 6 months ago
The writing of @server
in service
is no longer supported. You can modify the code in this way:
service shorturl-api {
- @server(
- handler: ShortenHandler
- )
+ @handler ShortenHandler
get /shorten(shortenReq) returns(shortenResp)
- @server(
- handler: ExpandHandler
- )
+ @handler ExpandHandler
get /expand(expandReq) returns(expandResp)
}
@server
is used to define the properties that used in server side. To find its specific style of writing, you can refer to the service grammar block in the file tools/goctl/api/parser/readme.md as below:
eg2:规范写法(推荐)
@server(
jwt: Auth
group: foo
middleware: AuthMiddleware
)
service foo-api{
@doc "foo"
@handler: foo
post /foo/:id (Foo) returns (Bar)
}
service foo-api{
@handler ping
get /ping
@doc "foo"
@handler: bar
post /bar/:id (Foo)
}
close
位置: https://github.com/zeromicro/zero-doc/blob/main/doc/shorturl.md
教程说 api/shorturl.api 文件的代码如下:
执行
goctl api go -api shorturl.api -dir .
报错:
shorturl.api 22:3 syntax error: expected '@handler' | '}', got '@server'
@server语句块是否应该放外面