Re:Mux – A lightweight, fast HTTP request router for Go
by daenney on Monday December 05, 2016 @11:50AM
(#13106760)
Do you know how it stacks up to httprouter for example? We can run benchmarks all day but it would be cool if you happened to have some real production statistics, by any change?
Re:Mux – A lightweight, fast HTTP request router for Go
by buro9 on Monday December 05, 2016 @01:00PM
(#13107556)
They're in the same ballpark, choosing one over the other was preference.
The benchmarks skew slightly in favour of httprouter, but only because pressly/chi embraces use of req.Context and this does a few ops. If you add req.Context use to httprouter they're basically the same.
If you're doing work with Context, you aren't going to be able to measure a difference that you'll care about.
If you're just serving static files, perhaps you'll care.
Re:Mux – A lightweight, fast HTTP request router for Go
by mmgutz on Monday December 05, 2016 @02:38PM
(#13108571)
httprouter is unforgiving with routes. IIRC, having both of these routes are not allowed
/users/:id
/users/create
Seems like a common use case.
Re:Mux – A lightweight, fast HTTP request router for Go
by peterkieltyka on Monday December 05, 2016 @03:45PM
(#13109345)
Interesting.. and btw, pressly/chi supports those routes easily, among many other combinations. Chi was designed to be very composeable with middlewares, subrouters and handlers. The idea is to consider the request passing through a "flow" of layers, handling and building the response along the way. This makes it easier to reason and organize each piece separately and then connect it all together.
Re:Mux – A lightweight, fast HTTP request router for Go
by bmurphy1976 on Monday December 05, 2016 @01:01PM
(#13107570)
It also uses the new context package which is a huge plus in my book.
The list of those using it in production includes:
- Pressly
- Cloudflare
- Heroku
- 99designs
- Origami
- IT Jobs Watch
- CrowdRiff
At Cloudflare it's our default router for internal APIs, which are all written in Go.
(and yes it uses a trie)