Skip to content

Commit

Permalink
Use FullName for service route generation (#601)
Browse files Browse the repository at this point in the history
Use the protobuf runtime's `FullName` rather than our own, bug-prone
implementation.

Fixes #597.

---------

Co-authored-by: Akshay Shah <akshayjshah@users.noreply.github.com>
  • Loading branch information
emcfarlane and akshayjshah committed Oct 3, 2023
1 parent 5efbe02 commit 8a0c89f
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions cmd/protoc-gen-connect-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func generateServerConstructor(g *protogen.GeneratedFile, service *protogen.Serv
}
g.P(")")
}
g.P(`return "/`, reflectionName(service), `/", `, httpPackage.Ident("HandlerFunc"), `(func(w `, httpPackage.Ident("ResponseWriter"), `, r *`, httpPackage.Ident("Request"), `){`)
g.P(`return "/`, service.Desc.FullName(), `/", `, httpPackage.Ident("HandlerFunc"), `(func(w `, httpPackage.Ident("ResponseWriter"), `, r *`, httpPackage.Ident("Request"), `){`)
g.P("switch r.URL.Path {")
for _, method := range service.Methods {
g.P("case ", procedureConstName(method), ":")
Expand Down Expand Up @@ -510,10 +510,6 @@ func procedureHandlerName(m *protogen.Method) string {
return fmt.Sprintf("%s%sHandler", unexport(m.Parent.GoName), m.GoName)
}

func reflectionName(service *protogen.Service) string {
return fmt.Sprintf("%s.%s", service.Desc.ParentFile().Package(), service.Desc.Name())
}

func isDeprecatedService(service *protogen.Service) bool {
serviceOptions, ok := service.Desc.Options().(*descriptorpb.ServiceOptions)
return ok && serviceOptions.GetDeprecated()
Expand Down

0 comments on commit 8a0c89f

Please sign in to comment.