Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Golang context.Context #224

Open
khash opened this issue Dec 17, 2017 · 0 comments
Open

Support for Golang context.Context #224

khash opened this issue Dec 17, 2017 · 0 comments

Comments

@khash
Copy link

khash commented Dec 17, 2017

I understand that the library uses Request.Env as a way to pass context between middlewares (#153) but this "context" doesn't go beyond middlewares that don't understand rest.Request. For example it is possible to imaging having the authenticated user on a native Golang context.Context object that is available across a system as the first parameter of all functions as per Golang recommendations. This becomes more useful for example when TLS client certificates are used and there is more than just the username that can be passed around (like PeerCertificates).

It would be very helpful to know if there is a way to make this happen. Attempting to fetch objects from Request.env in a middleware and putting them on the request.Context() using WithContext doesn't work as WithContext returns an http.Request which cannot be passed as a rest.Request. Also even if we open up the entire stack to include a context and add a context attribute to rest.Request all the existing middleware need to change without a backward compatible way.

I wonder what @ant0ine and others think of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant