Settings

Theme

Golang httprouter fork (http.Handler)

github.com

1 points by kellros 11 years ago · 3 comments

Reader

Merkur 11 years ago

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

  • kellrosOP 11 years ago

    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

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection