MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / defaultAPIOptions

Function defaultAPIOptions

internal/descriptor/services.go:229–246  ·  view source on GitHub ↗
(svc *Service, md *descriptorpb.MethodDescriptorProto)

Source from the content-addressed store, hash-verified

227}
228
229func defaultAPIOptions(svc *Service, md *descriptorpb.MethodDescriptorProto) (*options.HttpRule, error) {
230 // FQSN prefixes the service's full name with a '.', e.g.: '.example.ExampleService'
231 fqsn := strings.TrimPrefix(svc.FQSN(), ".")
232
233 // This generates an HttpRule that matches the gRPC mapping to HTTP/2 described in
234 // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests
235 // i.e.:
236 // * method is POST
237 // * path is "/<service name>/<method name>"
238 // * body should contain the serialized request message
239 rule := &options.HttpRule{
240 Pattern: &options.HttpRule_Post{
241 Post: fmt.Sprintf("/%s/%s", fqsn, md.GetName()),
242 },
243 Body: "*",
244 }
245 return rule, nil
246}
247
248func (r *Registry) newParam(meth *Method, path string) (Parameter, error) {
249 msg := meth.RequestType

Callers 1

loadServicesMethod · 0.85

Calls 2

FQSNMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected