respond icon indicating copy to clipboard operation
respond copied to clipboard

rewrite to use nbio/httpcontext instead of map and locks

Open zbindenren opened this issue 9 years ago • 2 comments

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 :-)

zbindenren avatar Sep 30 '15 12:09 zbindenren

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 [email protected] 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.

matryer avatar Sep 30 '15 12:09 matryer

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

zbindenren avatar Oct 01 '15 13:10 zbindenren