Enter the path where the API needs to be generated
[email protected] api % pwd
/Users/myself/Golang/common_project/src/shorturl/api
[email protected] api %
- Start build
[email protected] api % goctl api -o shorturl.api Done. [email protected] api % pwd /Users/myself/Golang/common_project/src/shorturl/api [email protected] api % ls shorturl.api [email protected] api %
Default content
syntax = "v1"
info(
title: // TODO: add title
desc: // TODO: add description
author: "donglei"
email: "[email protected]"
)
type request {
// TODO: add members here and delete this comment
}
type response {
// TODO: add members here and delete this comment
}
service shorturl-api {
@handler GetUser // TODO: set handler name and delete this comment
get /users/id/:userId(request) returns(response)
@handler CreateUser // TODO: set handler name and delete this comment
post /users/create(request)
}
Error field para1 is not set
This will report an error
Prompt field para1 is not set
type Request1 {
// Para1 string `json:"para1,optional"`
Para1 string `json:"para1"`
}
It won't
type Request1 {
Para1 string `json:"para1,optional"`
//Para1 string `json:"para1"`
}
This work adoptsCC agreement, reprint must indicate the author and the link to this article