matryer / respond

Idiomatic API responses for Go.
MIT License
88 stars 10 forks source link

rewrite to use nbio/httpcontext instead of map and locks #3

Open zbindenren opened 9 years ago

zbindenren commented 9 years ago

Hi Mat

I watched your London gopher talk and became aware of the response package. Great talk BTW.

I like the respond package, but what I didn't like, was the usage of locks in the options handler.

I rewrote the package to use https://github.com/nbio/httpcontext for contexts. It stores the request context directly in the http.Request by mutating the request.Body, avoiding the use of a global mutex and per-request teardown.

And it passes your tests :-)

matryer commented 9 years ago

Very cool - I wonder if it’s worth benchmarking the two solutions so we can understand the difference under load?

On 30 Sep 2015, at 13:10, Rene Zbinden notifications@github.com wrote:

Hi Mat

I watched your London gopher talk and became aware of the response package. Great talk BTW.

I like the respond package, but what I didn't like, was the usage of locks in the options handler.

I rewrote the package to use https://github.com/nbio/httpcontext https://github.com/nbio/httpcontext for contexts. It stores the request context directly in the http.Request by mutating the request.Body, avoiding the use of a global mutex and per-request teardown.

And it passes your tests :-)

You can view, comment on, or merge this pull request online at:

https://github.com/matryer/respond/pull/3 https://github.com/matryer/respond/pull/3 Commit Summary

rewrite to use nbio/httpcontext instead of map and locks File Changes

M respond.go https://github.com/matryer/respond/pull/3/files#diff-0 (53) Patch Links:

https://github.com/matryer/respond/pull/3.patch https://github.com/matryer/respond/pull/3.patch https://github.com/matryer/respond/pull/3.diff https://github.com/matryer/respond/pull/3.diff — Reply to this email directly or view it on GitHub https://github.com/matryer/respond/pull/3.

zbindenren commented 9 years ago

I did a small Test with https://github.com/rakyll/boom and it didn't show any meaningful differences.