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

Function isHandlerMethod

component/method.go:52–77  ·  view source on GitHub ↗

isHandlerMethod decide a method is suitable handler method

(method reflect.Method)

Source from the content-addressed store, hash-verified

50
51// isHandlerMethod decide a method is suitable handler method
52func isHandlerMethod(method reflect.Method) bool {
53 mt := method.Type
54 // Method must be exported.
55 if method.PkgPath != "" {
56 return false
57 }
58
59 // Method needs three ins: receiver, *Session, []byte or pointer.
60 if mt.NumIn() != 3 {
61 return false
62 }
63
64 // Method needs one outs: error
65 if mt.NumOut() != 1 {
66 return false
67 }
68
69 if t1 := mt.In(1); t1.Kind() != reflect.Ptr || t1 != typeOfSession {
70 return false
71 }
72
73 if (mt.In(2).Kind() != reflect.Ptr && mt.In(2) != typeOfBytes) || mt.Out(0) != typeOfError {
74 return false
75 }
76 return true
77}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…