|
|
@ -9,6 +9,11 @@ import ( |
|
|
|
var httpTemplate = ` |
|
|
|
var httpTemplate = ` |
|
|
|
{{$svrType := .ServiceType}} |
|
|
|
{{$svrType := .ServiceType}} |
|
|
|
{{$svrName := .ServiceName}} |
|
|
|
{{$svrName := .ServiceName}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{{- range .Methods}} |
|
|
|
|
|
|
|
const Operation{{.OriginalName}} = "/{{$svrName}}/{{.OriginalName}}" |
|
|
|
|
|
|
|
{{- end}} |
|
|
|
|
|
|
|
|
|
|
|
type {{.ServiceType}}HTTPServer interface { |
|
|
|
type {{.ServiceType}}HTTPServer interface { |
|
|
|
{{- range .MethodSets}} |
|
|
|
{{- range .MethodSets}} |
|
|
|
{{.Name}}(context.Context, *{{.Request}}) (*{{.Reply}}, error) |
|
|
|
{{.Name}}(context.Context, *{{.Request}}) (*{{.Reply}}, error) |
|
|
@ -46,7 +51,7 @@ func _{{$svrType}}_{{.Name}}{{.Num}}_HTTP_Handler(srv {{$svrType}}HTTPServer) fu |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
{{- end}} |
|
|
|
{{- end}} |
|
|
|
http.SetOperation(ctx,"/{{$svrName}}/{{.OriginalName}}") |
|
|
|
http.SetOperation(ctx,Operation{{.OriginalName}}) |
|
|
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
|
|
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
|
|
|
return srv.{{.Name}}(ctx, req.(*{{.Request}})) |
|
|
|
return srv.{{.Name}}(ctx, req.(*{{.Request}})) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -79,7 +84,7 @@ func (c *{{$svrType}}HTTPClientImpl) {{.Name}}(ctx context.Context, in *{{.Reque |
|
|
|
var out {{.Reply}} |
|
|
|
var out {{.Reply}} |
|
|
|
pattern := "{{.Path}}" |
|
|
|
pattern := "{{.Path}}" |
|
|
|
path := binding.EncodeURL(pattern, in, {{not .HasBody}}) |
|
|
|
path := binding.EncodeURL(pattern, in, {{not .HasBody}}) |
|
|
|
opts = append(opts, http.Operation("/{{$svrName}}/{{.OriginalName}}")) |
|
|
|
opts = append(opts, http.Operation(Operation{{.OriginalName}})) |
|
|
|
opts = append(opts, http.PathTemplate(pattern)) |
|
|
|
opts = append(opts, http.PathTemplate(pattern)) |
|
|
|
{{if .HasBody -}} |
|
|
|
{{if .HasBody -}} |
|
|
|
err := c.cc.Invoke(ctx, "{{.Method}}", path, in{{.Body}}, &out{{.ResponseBody}}, opts...) |
|
|
|
err := c.cc.Invoke(ctx, "{{.Method}}", path, in{{.Body}}, &out{{.ResponseBody}}, opts...) |
|
|
|