mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
optimize api new (#216)
This commit is contained in:
parent
24fb29a356
commit
e0afe0b4bb
@ -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…
Reference in New Issue
Block a user