MCPcopy
hub / github.com/lonng/nano / suitableHandlerMethods

Method suitableHandlerMethods

component/service.go:71–90  ·  view source on GitHub ↗

suitableMethods returns suitable methods of typ

(typ reflect.Type)

Source from the content-addressed store, hash-verified

69
70// suitableMethods returns suitable methods of typ
71func (s *Service) suitableHandlerMethods(typ reflect.Type) map[string]*Handler {
72 methods := make(map[string]*Handler)
73 for m := 0; m < typ.NumMethod(); m++ {
74 method := typ.Method(m)
75 mt := method.Type
76 mn := method.Name
77 if isHandlerMethod(method) {
78 raw := false
79 if mt.In(2) == typeOfBytes {
80 raw = true
81 }
82 // rewrite handler name
83 if s.Options.nameFunc != nil {
84 mn = s.Options.nameFunc(mn)
85 }
86 methods[mn] = &Handler{Method: method, Type: mt.In(2), IsRawArg: raw}
87 }
88 }
89 return methods
90}
91
92// ExtractHandler extract the set of methods from the
93// receiver value which satisfy the following conditions:

Callers 1

ExtractHandlerMethod · 0.95

Calls 1

isHandlerMethodFunction · 0.85

Tested by

no test coverage detected