Skip to content

Support for Golang context.Context #224

@khash

Description

@khash

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions