MainHandlerName tries to find the main handler that end-developer registered on the provided chain of handlers and returns its function name.
(handlers ...interface{})
| 210 | // MainHandlerName tries to find the main handler that end-developer |
| 211 | // registered on the provided chain of handlers and returns its function name. |
| 212 | func MainHandlerName(handlers ...interface{}) (name string, index int) { |
| 213 | if len(handlers) == 0 { |
| 214 | return |
| 215 | } |
| 216 | |
| 217 | if hs, ok := handlers[0].(Handlers); ok { |
| 218 | tmp := make([]interface{}, 0, len(hs)) |
| 219 | for _, h := range hs { |
| 220 | tmp = append(tmp, h) |
| 221 | } |
| 222 | |
| 223 | return MainHandlerName(tmp...) |
| 224 | } |
| 225 | |
| 226 | for i := 0; i < len(handlers); i++ { |
| 227 | name = HandlerName(handlers[i]) |
| 228 | if name == "" { |
| 229 | continue |
| 230 | } |
| 231 | |
| 232 | index = i |
| 233 | if !ingoreMainHandlerName(name) { |
| 234 | break |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | return |
| 239 | } |
| 240 | |
| 241 | func trimHandlerName(name string) string { |
| 242 | // trim the path for Iris' internal middlewares, e.g. |
no test coverage detected
searching dependent graphs…