async-graphql / examples

217 stars 54 forks source link

How to access the request headers in async-graphql ? #48

Closed lmnzx closed 2 years ago

lmnzx commented 2 years ago

I am new to Rust and I couldn't figure out how to access the request headers in a Graphql request. I read the async-graphql docs, where Context is used to set the headers in the response but there is no function to get the request headers. It's would be great if you could show me how to do this. I am using async-graphql with poem.

sunli829 commented 2 years ago

This example can help you.

https://github.com/async-graphql/examples/blob/9cde888ee5f367d4f4d653a9fa9ec94722b855d1/poem/token-from-header/src/main.rs#L30