c9s / r3

libr3 is a high-performance path dispatching library. It compiles your route paths into a prefix tree (trie). By using the constructed prefix trie in the start-up time, you may dispatch your routes with efficiency
http://c9s.github.com/r3/bench.html
MIT License
816 stars 83 forks source link

multiple methods for a route #67

Closed freehaha closed 10 years ago

freehaha commented 10 years ago

Hi,

Thanks for the awesome library. However, I was implementing a Go http mux based on r3 and found some strange behavior:

I found that inserting routes with different method but the same path seems to work only once. Is this the intended behavior?

If it is, then router implementations based on r3 will have to roll out their own method dispatchers on the leaf nodes and insert catch-it-all (METHOD_GET|METHOD_POST|METHOD ....) routes on every paths registered because there are no API to remove/replace existing routes. This makes routes kind of meaningless compared to paths, IMO.

Example behavior here: https://gist.github.com/freehaha/514038ec448667fc22e8

c9s commented 10 years ago

Looks like that's what we have to fix.

The original design does not consider about re-insert the same paths with different request method. but you may insert one path with multiple request method.

I think we need to handle this kind of usage. :)

freehaha commented 10 years ago

ah, apparently I was using some ancient version before 03b5d10. My problem is fixed after that commit. Thanks anyway for the reply.

c9s commented 10 years ago

great. :) then I close this issue.