Skip to content

Commit

Permalink
optimize api new (zeromicro#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingxt authored and jeyrce committed Aug 25, 2021
1 parent 4df9ab6 commit 1ef77f6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/goctl/api/new/newservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package new
import (
"os"
"path/filepath"
"strings"
"text/template"

"github.com/tal-tech/go-zero/tools/goctl/api/gogen"
Expand All @@ -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);
}
`

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 1ef77f6

Please sign in to comment.