From e0afe0b4bbf5c2cc0208726eb5adb82ce0ef3680 Mon Sep 17 00:00:00 2001 From: kingxt Date: Thu, 19 Nov 2020 16:48:48 +0800 Subject: [PATCH] optimize api new (#216) --- tools/goctl/api/new/newservice.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/goctl/api/new/newservice.go b/tools/goctl/api/new/newservice.go index 18f811ab..7f5c8aa0 100644 --- a/tools/goctl/api/new/newservice.go +++ b/tools/goctl/api/new/newservice.go @@ -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 }