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

Add tower server example #375

Merged
merged 1 commit into from
Jun 22, 2020
Merged

Add tower server example #375

merged 1 commit into from
Jun 22, 2020

Conversation

belak
Copy link
Contributor

@belak belak commented Jun 18, 2020

Note that this also adds impl From<Status> for http::Response<BoxBody>
in order to make writing middleware which can return an error much
easier.

Motivation

This is based off the example from https://gist.github.com/LucioFranco/9d5cab419797f54fc7b96bc409d8c6e8. It has been expanded into something a little more complex which requires specifying the Request/Response types but allows for intercepting metadata values with an async context. This allows lookups to happen to verify things like auth tokens.

Solution

Most of the code here is the example, but it also replaces Grpc::map_status with an impl From<Status> for http::Response<tonic::body::BoxBody> in order to make it easier to write middleware which can return an error.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for now, can we back out the status change and the auth header check and just leave a comment. I'd like to tackle the status change in another PR and think about it a bit more.

Note that this also adds `impl From<Status> for http::Response<BoxBody>`
in order to make writing middleware which can return an error much
easier.
@belak
Copy link
Contributor Author

belak commented Jun 19, 2020

Just for now, can we back out the status change and the auth header check and just leave a comment. I'd like to tackle the status change in another PR and think about it a bit more.

Done. I've also opened #376 for discussion around adding some method to convert from Status to an http::Response.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@LucioFranco LucioFranco merged commit 80e90e3 into hyperium:master Jun 22, 2020
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

Successfully merging this pull request may close these issues.

2 participants