interagent / pliny

An opinionated toolkit for writing excellent APIs in Ruby.
MIT License
801 stars 73 forks source link

Add mechanism for additional headers. #320

Closed bigkevmcd closed 6 years ago

bigkevmcd commented 6 years ago

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?

gudmundur commented 6 years ago

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. 😢