optimize api new (#216)

master v1.0.28
kingxt 4 years ago committed by GitHub
parent 24fb29a356
commit e0afe0b4bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,6 +3,7 @@ package new
import (
"os"
"path/filepath"
"strings"
"text/template"
"github.com/tal-tech/go-zero/tools/goctl/api/gogen"
@ -20,8 +21,8 @@ type Response {
}
service {{.name}}-api {
@handler GreetHandler
get /greet/from/:name(Request) returns (Response);
@handler {{.handler}}Handler
get /from/:name(Request) returns (Response);
}
`
@ -53,7 +54,8 @@ func NewService(c *cli.Context) error {
defer fp.Close()
t := template.Must(template.New("template").Parse(apiTemplate))
if err := t.Execute(fp, map[string]string{
"name": dirName,
"name": dirName,
"handler": strings.Title(dirName),
}); err != nil {
return err
}

Loading…
Cancel
Save