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 mechanism for additional headers. #320

Merged
merged 1 commit into from
Dec 4, 2017
Merged

Add mechanism for additional headers. #320

merged 1 commit into from
Dec 4, 2017

Conversation

bigkevmcd
Copy link
Contributor

To add additional headers to responses, we have to resort to something like...

allowed_cors_headers = Pliny::Middleware::CORS.send(:remove_const, :ALLOW_HEADERS).dup
allowed_cors_headers << "X-Origin"

Pliny::Middleware::CORS::ALLOW_HEADERS = allowed_cors_headers.freeze

It'd be nice if we could just configure the response headers globally when configuring our app?

@@ -32,11 +38,15 @@ def cors_request?(env)
env.has_key?("HTTP_ORIGIN")
end

def allow_headers
ALLOW_METHODS + @@additional_headers
Copy link

@raulb raulb Nov 30, 2017

Choose a reason for hiding this comment

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

s/ALLOW_METHODS/ALLOW_HEADERS

@gudmundur
Copy link
Member

Nicely done. I'm glad to see this contribution as the example you gave is something that's made my eyes all teary a few times. 😢

@gudmundur gudmundur merged commit 26eef13 into interagent:master Dec 4, 2017
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.

3 participants