diff --git a/cmd/gin-kit/main.go b/cmd/gin-kit/main.go index f0fb73c..6ed6a1e 100644 --- a/cmd/gin-kit/main.go +++ b/cmd/gin-kit/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" protogen2 "git.diulo.com/mogfee/kit/protogen" "google.golang.org/protobuf/compiler/protogen" @@ -9,14 +10,17 @@ import ( ) func main() { + var httpPrefix = flag.String("prefix", "", "http prefix") u := &Kit{ imports: map[string]string{}, + prefix: *httpPrefix, } protogen.Options{}.Run(u.Generate) } type Kit struct { imports map[string]string + prefix string } func (u *Kit) addImports(imp string) { @@ -61,6 +65,10 @@ func (u *Kit) Generate(plugin *protogen.Plugin) error { if method == "" { continue } + if u.prefix != "" { + path = u.prefix + path + } + t.P(`app.`, method, `("`, path, `",http`, m.GoName, `Handler(srv,m...))`) } t.P(`}`)