fix(cmd/http): fixed cannot declare a route with a regular expression (#1608)

* fix(cmd/http): fixed cannot declare a route with a regular expression
pull/1613/head
包子 3 years ago committed by GitHub
parent cd79c2a458
commit 5aac2ef5a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      cmd/protoc-gen-go-http/http.go

@ -164,6 +164,9 @@ func buildMethodDesc(g *protogen.GeneratedFile, m *protogen.Method, method, path
if strings.TrimSpace(field) == "" { if strings.TrimSpace(field) == "" {
continue continue
} }
if strings.Contains(field, ":") {
field = strings.Split(field, ":")[0]
}
fd := fields.ByName(protoreflect.Name(field)) fd := fields.ByName(protoreflect.Name(field))
if fd == nil { if fd == nil {
fmt.Fprintf(os.Stderr, "\u001B[31mERROR\u001B[m: The corresponding field '%s' declaration in message could not be found in '%s'\n", v, path) fmt.Fprintf(os.Stderr, "\u001B[31mERROR\u001B[m: The corresponding field '%s' declaration in message could not be found in '%s'\n", v, path)

Loading…
Cancel
Save