isHandlerMethod decide a method is suitable handler method
(method reflect.Method)
| 50 | |
| 51 | // isHandlerMethod decide a method is suitable handler method |
| 52 | func 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…