Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Golang httprouter fork (http.Handler) (github.com/shelakel)
1 point by kellros on Feb 17, 2015 | hide | past | favorite | 2 comments



Why did you fork? What are the new use cases?


In the spirit of OSS I forked httprouter instead of just keeping the changes locally. I hope that the implementation can prove as a reference in improving httprouter or other Golang muxers.

I like httprouter, but dislike how the dependency on httprouter.Params pollutes your packages that need to expose httprouter.Handle.

I also dislike the non-standard handler, even with map[string]string parameters. From what I read the proper way to "scope" things in Go is to pass "it" as a parameter to a method; so the dislike is just personal preference. Currently the only way to retain the standard (http.Handler) interface compatibility is to use a synchronized reference map e.g. map[*http.Request]map[string]string, similar to Gorilla Contexts' implementation with only the parameters associated with the request.

Anyway, after all those changes it was a short jump to implement basic middleware helpers and expose an initializer with a standard implementation to associate the parameters with the request.

I hope that answered your questions and thanks for showing interest :) P.S. Check the updated example usage




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: