bmizerany / pat

MIT License
1.43k stars 115 forks source link

Adding handler now updates a handler if registered #24

Closed tusj closed 8 years ago

tusj commented 11 years ago

When a handler was added, there was no check whether the pattern was already registered. Now, if the pattern is registered, it is updated. It may be better to throw an error, or add a update flag, but for my use case, updating the handler is correct.

In any case, it is an error to add two handlers with same pattern.

cespare commented 8 years ago

The pat docs say this:

A pattern ending with a slash will get an implicit redirect to it's non-slash version. For example: Get("/foo/", handler) will implicitly register Get("/foo", handler). You may override it by registering Get("/foo", anotherhandler) before the slash version.

That will no longer work after this change, because the redirect will override the user's original handler. Therefore, this change will break existing users.