MCPcopy Create free account
hub / github.com/kataras/iris / MethodHandler

Method MethodHandler

hero/struct.go:182–189  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

180// Second input is optional,
181// even zero is a valid value and can resolve path parameters correctly if from root party.
182func (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}

Callers 4

TestStructFunction · 0.80
TestStructErrorHandlerFunction · 0.80
TestStructFieldsSorterFunction · 0.80
handlerOfMethod · 0.80

Calls 2

TypeMethod · 0.80
makeHandlerFunction · 0.70

Tested by 3

TestStructFunction · 0.64
TestStructErrorHandlerFunction · 0.64
TestStructFieldsSorterFunction · 0.64