Skip to content

Commit

Permalink
feat: add OriginalComment
Browse files Browse the repository at this point in the history
  • Loading branch information
fynntang committed Aug 29, 2023
1 parent 6ddd4c6 commit b1e1fa7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions protoc-gen-go-http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,16 @@ func buildMethodDesc(g *protogen.GeneratedFile, m *protogen.Method, method, path
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,
Comment2: m.Comments.Trailing.String(),
Path: replacePathToGinPath(path),
Method: method,
HasVars: len(vars) > 0,
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,
OriginalComment: strings.ReplaceAll(comment, string(m.Desc.Name())+" ", ""),
Path: replacePathToGinPath(path),
Method: method,
HasVars: len(vars) > 0,
}
}

Expand Down
16 changes: 8 additions & 8 deletions protoc-gen-go-http/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var httpTemplate = `
{{$svrName := .ServiceName}}
{{- range .MethodSets}}
const Route{{$svrType}}{{.OriginalName}} = "{{.Path}}" {{- if ne .Comment2 ""}} {{.Comment2}} {{- end}}
const Route{{$svrType}}{{.OriginalName}} = "{{.Path}}" {{- if ne .OriginalComment ""}} {{.OriginalComment}} {{- end}}
{{- end}}
type {{.ServiceType}}HTTPServer interface {
Expand Down Expand Up @@ -102,13 +102,13 @@ type serviceDesc struct {

type methodDesc struct {
// method
Name string
OriginalName string // The parsed original name
Num int
Request string
Reply string
Comment string
Comment2 string
Name string
OriginalName string // The parsed original name
Num int
Request string
Reply string
Comment string
OriginalComment string
// http_rule
Path string
Method string
Expand Down

0 comments on commit b1e1fa7

Please sign in to comment.