Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Expose extensions map in Request #94

Closed
ebkalderon opened this issue Nov 24, 2018 · 2 comments
Closed

Expose extensions map in Request #94

ebkalderon opened this issue Nov 24, 2018 · 2 comments

Comments

@ebkalderon
Copy link

The underlying http::Request type from which the tower_grpc::Request type is made from has a useful method called extensions_mut(), which can store arbitrary data alongside the request, as long as it is Send + Sync + 'static. The data can then be queried later with:

if let Some(extra_metadata) = request.extensions().get::<MyMetadata>() {
    // Respond to request one way.
} else {
    // Respond to request another way.
}

It would be nice to preserve this metadata in the tower_grpc::Request and make it accessible through an extensions() method.

@per-gron
Copy link
Collaborator

I explained some concerns I have about exposing HTTP and language interoperability in #95, but I still like the idea of having a getter that returns an Option like this, especially if the API would be easy to use with protobuf types. I think an API that looks almost the same as this could be built on top of gRPC custom metadata primitives (which are being worked on now in #92 and #90).

@ebkalderon
Copy link
Author

Sounds good. I've decided to close the associated PR #95 as well as this issue in favor of waiting for your upcoming PR with MetadataMap support to land. Thanks for working on this.

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

No branches or pull requests

2 participants