Module: Roda::RodaPlugins::DefaultHeaders
- Defined in:
- lib/roda/plugins/default_headers.rb
Overview
The default_headers plugin accepts a hash of headers, and overrides the default_headers method in the response class to be a copy of the headers.
Note that when using this module, you should not attempt to mutate of the values set in the default headers hash.
Example:
plugin :default_headers, 'Content-Type'=>'text/csv'
You can also modify the default headers later:
plugin :default_headers
default_headers['Foo'] = 'bar'
default_headers.merge!('Bar'=>'baz')
Defined Under Namespace
Modules: ClassMethods, ResponseMethods
Class Method Summary collapse
-
.configure(app, headers = {}) ⇒ Object
Merge the given headers into the existing default headers, if any.
Class Method Details
.configure(app, headers = {}) ⇒ Object
Merge the given headers into the existing default headers, if any.
22 23 24 25 26 27 |
# File 'lib/roda/plugins/default_headers.rb', line 22 def self.configure(app, headers={}) app.instance_eval do @default_headers ||= {} @default_headers.merge!(headers) end end |