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