李伟乐 1 year ago
parent bb499a0012
commit 995f16c169
  1. 8
      cmd/gin-kit/main.go

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

Loading…
Cancel
Save