|
|
@ -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(`}`) |
|
|
|