MCPcopy
hub / github.com/gofiber/fiber / validateRegexHandler

Function validateRegexHandler

constraint.go:50–66  ·  view source on GitHub ↗
(handler any)

Source from the content-addressed store, hash-verified

48}
49
50func 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.

Callers 2

RoutePatternMatchFunction · 0.85
NewFunction · 0.85

Calls 1

TypeMethod · 0.65

Tested by

no test coverage detected