The goal of a (proper) router is to decouple routes from handlers, thus 
making refactoring easier by adopting a declarative form rather than an 
imperative one. It's the good old builder pattern. By deeming it 
unnecessary you did nothing but couple your handlers with your routes. 
That's the only thing you did. You didn't make your code easier to read, 
you cluttered it with unnecessary imperative logic that could be simply 
abstracted while remaining no less readable if not more. 

Your solution certainly doesn't get more readable as the amount of routes 
in an app gets larger. 

Le lundi 19 juin 2017 00:02:37 UTC+2, Axel Wagner a écrit :
>
> Hey gophers,
>
> in an attempt to rein in the HTTP router epidemic, I tried writing down a) 
> why I think *any* router/muxer might not be a good thing to use (much 
> less write) and b) what I consider good, practical advice on how to route 
> requests instead. It's not rocket science or especially novel, but I wanted 
> to provide more useful advice than just saying "just use net/http" and 
> haven't seen that a lot previously.
>
> Feedback is welcome :)
> http://blog.merovius.de/2017/06/18/how-not-to-use-an-http-router.html
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to