feat: add comment to http server interface method (#2657)

Co-authored-by: gogogo <gogogo@aliyun.com>
pull/2670/head
thinkgo 2 years ago committed by GitHub
parent 54f19c1dcb
commit d0b1d84850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      cmd/protoc-gen-go-http/http.go
  2. 4
      cmd/protoc-gen-go-http/template.go

@ -198,12 +198,17 @@ func buildMethodDesc(g *protogen.GeneratedFile, m *protogen.Method, method, path
}
}
}
comment := m.Comments.Leading.String() + m.Comments.Trailing.String()
if comment != "" {
comment = "// " + m.GoName + strings.TrimPrefix(strings.TrimSuffix(comment, "\n"), "//")
}
return &methodDesc{
Name: m.GoName,
OriginalName: string(m.Desc.Name()),
Num: methodSets[m.GoName],
Request: g.QualifiedGoIdent(m.Input.GoIdent),
Reply: g.QualifiedGoIdent(m.Output.GoIdent),
Comment: comment,
Path: path,
Method: method,
HasVars: len(vars) > 0,

@ -16,6 +16,9 @@ const Operation{{$svrType}}{{.OriginalName}} = "/{{$svrName}}/{{.OriginalName}}"
type {{.ServiceType}}HTTPServer interface {
{{- range .MethodSets}}
{{- if ne .Comment ""}}
{{.Comment}}
{{- end}}
{{.Name}}(context.Context, *{{.Request}}) (*{{.Reply}}, error)
{{- end}}
}
@ -114,6 +117,7 @@ type methodDesc struct {
Num int
Request string
Reply string
Comment string
// http_rule
Path string
Method string

Loading…
Cancel
Save