(handler any)
| 48 | } |
| 49 | |
| 50 | func validateRegexHandler(handler any) any { |
| 51 | if handler == nil { |
| 52 | return regexp.MustCompile |
| 53 | } |
| 54 | handlerValue := reflect.ValueOf(handler) |
| 55 | handlerType := handlerValue.Type() |
| 56 | if handlerType.Kind() != reflect.Func || handlerValue.IsNil() { |
| 57 | panic("fiber: Config.RegexHandler must be a non-nil function") |
| 58 | } |
| 59 | if handlerType.NumIn() != 1 || handlerType.In(0) != stringType || handlerType.NumOut() != 1 { |
| 60 | panic("fiber: Config.RegexHandler must have signature func(string) T") |
| 61 | } |
| 62 | if !handlerType.Out(0).Implements(regexMatcherType) { |
| 63 | panic("fiber: Config.RegexHandler return type must support MatchString(string) bool") |
| 64 | } |
| 65 | return handler |
| 66 | } |
| 67 | |
| 68 | // ConstraintHandler is the interface that all constraints must implement. |
| 69 | // Built-in and custom constraints are treated uniformly through this interface. |
no test coverage detected