MethodHandler accepts a "methodName" that should be a valid an exported method of the struct and returns its converted Handler. Second input is optional, even zero is a valid value and can resolve path parameters correctly if from root party.
(methodName string, paramsCount int)
| 180 | // Second input is optional, |
| 181 | // even zero is a valid value and can resolve path parameters correctly if from root party. |
| 182 | func (s *Struct) MethodHandler(methodName string, paramsCount int) context.Handler { |
| 183 | m, ok := s.ptrValue.Type().MethodByName(methodName) |
| 184 | if !ok { |
| 185 | panic(fmt.Sprintf("struct: method: %s does not exist", methodName)) |
| 186 | } |
| 187 | |
| 188 | return makeHandler(m.Func, s.Container, paramsCount) |
| 189 | } |