MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / lookupMethodDescriptor

Function lookupMethodDescriptor

internal/grpcsrv/interceptors/auth.go:121–143  ·  view source on GitHub ↗
(fullMethod string)

Source from the content-addressed store, hash-verified

119}
120
121func lookupMethodDescriptor(fullMethod string) (protoreflect.MethodDescriptor, bool) {
122 parts := strings.Split(strings.TrimPrefix(fullMethod, "/"), "/")
123 if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
124 return nil, false
125 }
126 desc, err := protoregistry.GlobalFiles.FindDescriptorByName(protoreflect.FullName(parts[0]))
127 if err != nil {
128 return nil, false
129 }
130 svcDesc, ok := desc.(protoreflect.ServiceDescriptor)
131 if !ok {
132 return nil, false
133 }
134 methods := svcDesc.Methods()
135 name := protoreflect.Name(parts[1])
136 for i := 0; i < methods.Len(); i++ {
137 m := methods.Get(i)
138 if m.Name() == name {
139 return m, true
140 }
141 }
142 return nil, false
143}
144
145func isPublicMethod(method protoreflect.MethodDescriptor) bool {
146 opts := method.Options()

Callers 1

methodDescriptorFunction · 0.85

Calls 2

NameMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected