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

Method LookupMsg

internal/descriptor/registry.go:352–376  ·  view source on GitHub ↗

LookupMsg looks up a message type by "name". It tries to resolve "name" from "location" if "name" is a relative message name.

(location, name string)

Source from the content-addressed store, hash-verified

350// LookupMsg looks up a message type by "name".
351// It tries to resolve "name" from "location" if "name" is a relative message name.
352func (r *Registry) LookupMsg(location, name string) (*Message, error) {
353 if grpclog.V(1) {
354 grpclog.Infof("Lookup %s from %s", name, location)
355 }
356 if strings.HasPrefix(name, ".") {
357 m, ok := r.msgs[name]
358 if !ok {
359 return nil, fmt.Errorf("no message found: %s", name)
360 }
361 return m, nil
362 }
363
364 if !strings.HasPrefix(location, ".") {
365 location = fmt.Sprintf(".%s", location)
366 }
367 components := strings.Split(location, ".")
368 for len(components) > 0 {
369 fqmn := strings.Join(append(components, name), ".")
370 if m, ok := r.msgs[fqmn]; ok {
371 return m, nil
372 }
373 components = components[:len(components)-1]
374 }
375 return nil, fmt.Errorf("no message found: %s", name)
376}
377
378// LookupEnum looks up an enum type by "name".
379// It tries to resolve "name" from "location" if "name" is a relative enum name.

Calls

no outgoing calls