-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
What is the best way to access request headers? #1114
Comments
Some examples of headers that are commonly needed are:
So it would be good to have a Hapi strategy for accessing these and any others needed. Thoughts? |
I'm not familiar with another method (don't believe it exists), but using On Thu, Oct 24, 2013 at 5:27 PM, Jeff Barczewski
|
Just use |
Thanks Eran. Adding request.headers will be great so we don't have to access core object which could change in future. Good to have a light abstraction for some key things. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
In reading through the docs it wasn't clear what is the best way to access the request headers (or what is the hapi way).
I realize that one can go to
request.raw.req.headers
but from the docs, we are told to avoid using raw where possible, so is there a better way?I understand that it is nice to abstract things away where possible, and for some things like auth, one could read the headers in a plugin and then set something in the artifacts.
Maybe that's the recommended approach for other things too, read them in a plugin and set some business state in a plugin?
Thanks in advance for any suggestions or advice. I am enjoying using Hapi.
The text was updated successfully, but these errors were encountered: