-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Description
In the current state of the api the ValidateHttpRequest does the path lookup and the request validation at the same time. It ouputs an error slice of errors.ValidationError.
Issue is when you want to do composition in middleware you end up with logic like:
skipServe := false
valid, validationErrs := docValidator.ValidateHttpRequest(r)
if !valid {
for _, e := range validationErrs {
if opts.RouteNotFoundHook != nil && e.ValidationType == "path" && e.ValidationSubType == "missing" {
skipServe = opts.RouteNotFoundHook(e, w, r)
break
}
if opts.RouteValidationErrorHook != nil {
skipServe = opts.RouteValidationErrorHook(e, w, r)
break
}
}
}Solutions:
- Expose a specific error for a path not found
- Expose a function to check if the error is a path not found
wdyt?
Metadata
Metadata
Assignees
Labels
No labels