add micro.codec.Frame special type handling
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
ee4d83458f
commit
5d13b84c7a
1
http.go
1
http.go
@ -29,6 +29,7 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC
|
||||
|
||||
gfile.Import(contextPackage)
|
||||
gfile.Import(microApiPackage)
|
||||
|
||||
if genClient {
|
||||
gfile.Import(microClientPackage)
|
||||
gfile.Import(microClientHttpPackage)
|
||||
|
32
util.go
32
util.go
@ -10,19 +10,17 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var (
|
||||
httpMethodMap = map[string]string{
|
||||
"GET": "MethodGet",
|
||||
"HEAD": "MethodHead",
|
||||
"POST": "MethodPost",
|
||||
"PUT": "MethodPut",
|
||||
"PATCH": "MethodPatch",
|
||||
"DELETE": "MethodDelete",
|
||||
"CONNECT": "MethodConnect",
|
||||
"OPTIONS": "MethodOptions",
|
||||
"TRACE": "MethodTrace",
|
||||
}
|
||||
)
|
||||
var httpMethodMap = map[string]string{
|
||||
"GET": "MethodGet",
|
||||
"HEAD": "MethodHead",
|
||||
"POST": "MethodPost",
|
||||
"PUT": "MethodPut",
|
||||
"PATCH": "MethodPatch",
|
||||
"DELETE": "MethodDelete",
|
||||
"CONNECT": "MethodConnect",
|
||||
"OPTIONS": "MethodOptions",
|
||||
"TRACE": "MethodTrace",
|
||||
}
|
||||
|
||||
func unexport(s string) string {
|
||||
return strings.ToLower(s[:1]) + s[1:]
|
||||
@ -30,7 +28,7 @@ func unexport(s string) string {
|
||||
|
||||
func generateServiceClient(gfile *protogen.GeneratedFile, service *protogen.Service) {
|
||||
serviceName := service.GoName
|
||||
//if rule, ok := getMicroApiService(service); ok {
|
||||
// if rule, ok := getMicroApiService(service); ok {
|
||||
// gfile.P("// client wrappers ", strings.Join(rule.ClientWrappers, ", "))
|
||||
// }
|
||||
gfile.P("type ", unexport(serviceName), "Client struct {")
|
||||
@ -62,7 +60,11 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog
|
||||
if strings.HasPrefix(ref, "."+string(service.Desc.ParentFile().Package())+".") {
|
||||
ref = strings.TrimPrefix(ref, "."+string(service.Desc.ParentFile().Package())+".")
|
||||
}
|
||||
gfile.P(`errmap["`, rsp.Name, `"] = &`, ref, "{}")
|
||||
if ref == "micro.codec.Frame" {
|
||||
gfile.P(`errmap["`, rsp.Name, `"] = &`, microCodecPackage.Ident("Frame"), "{}")
|
||||
} else {
|
||||
gfile.P(`errmap["`, rsp.Name, `"] = &`, ref, "{}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ var (
|
||||
microClientPackage = protogen.GoImportPath("github.com/unistack-org/micro/v3/client")
|
||||
microServerPackage = protogen.GoImportPath("github.com/unistack-org/micro/v3/server")
|
||||
microClientHttpPackage = protogen.GoImportPath("github.com/unistack-org/micro-client-http/v3")
|
||||
microCodecPackage = protogen.GoImportPath("github.com/unistack-org/micro/v3/codec")
|
||||
timePackage = protogen.GoImportPath("time")
|
||||
deprecationComment = "// Deprecated: Do not use."
|
||||
versionComment = "v3.4.2"
|
||||
|
Loading…
Reference in New Issue
Block a user