-
Notifications
You must be signed in to change notification settings - Fork 6
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
How to set headers other than Content-type? #9
Comments
In prepping examples I just ran into this as well. I'm trying to think of what might be appropriate API. For example, we currently have the beautifully simple:
Some awful looking ideas are:
Will think some more. |
Well, we have: request.header("application/json"); but the only header it sets is the Content-type. |
ah, zoinks, sorry I missed that. Perfect! Maybe for other headers it should take two arguments:
|
I like that. Wonder if it could be called multiple times for multiple headers, or if an object might be the way to go, similar to {
'Content-Length': 1234,
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*'
} Maybe sending a string param indicates you're setting just the content-type, and sending an object lets you set a bunch of stuff. |
Agreed.. We should do this at the very least: |
Is there a way to send additional headers besides the content type used in header()? Is there a way to access the response object so I could, for example, set an access control header or send a 404?
If it's not possible with the existing servi API, I'm trying to figure out if there's a way to use another module to do it while still using servi for everything else. Basically, I see that node's http is being used behind the scenes, but can't figure out if there's a way to access it through any of servi's available methods.
The text was updated successfully, but these errors were encountered: