Skip to content

Path not found error handling #4

@zekth

Description

@zekth

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions