Skip to content

Mux does not prioritize most specific matching Handler #32

Description

@AdamSLevy

Currently the Mux prioritizes the Handler with the most specific Path, but if multiple Handlers are registered with the same Path, but with different criteria such as ContentType, the selected handler is undefined.

For example, I want a generic handler for a specific Host, and a more specific handler for a specific content type. If the content type matches, I want that more specific handler to be selected.

I suggest returning an additional parameter from ResponseMatcher.match that is the number of matching criteria. When selecting a ResponseMatcher in Mux.Handle the handler with the highest number of matching criteria should be selected. The path length can then be used as a tie breaker.

This would change behavior slightly in some cases, but mostly only where the behavior was already undefined.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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