Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change path matching #39

Open
AndrewBurian opened this issue Nov 27, 2018 · 0 comments
Open

Change path matching #39

AndrewBurian opened this issue Nov 27, 2018 · 0 comments

Comments

@AndrewBurian
Copy link
Owner

Change the way path matching works to be closer to the latest definition from http.ServeMux

  • Drop the * param in favour of using trailing slashes to indicate rooted trees
  • Rework the Route syntax to make this apparent

mux.Handle("/", h) should handle all paths without a more exact match, as it does in the go mux. Right now this is only achieved via mux.Handle("/*", h) and requires another definition for the root itself.

mux.Handle("thing", h) and mux.Handle("thing/", h) should differentiate between only an exactly match of thing and thing/* respectively. Without the exact definition, the rooted tree will also match thing directly.

Both thing AND thing/ should be able to be defined separately, as the go mux does, and result in different handlers. Being able to do this with the Route() syntax is challenging.
A possible implementation:

// registers a and b/ with no specific separate b handler
mux.Route("a").Route("b/")

// registers a, b, and b/
a := mux.Route("a")
a.Route("b")
a.Route("b/")

This is more confusing when the rooted tree comes in the middle of a chain

// Will register handlers for a, b/, and c, with no specific handler on b
mux.Route("a").Route("b/").Route("c")

// Requests to /a/b will go to the b/ handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant