Module: Roda::RodaPlugins::ResponseContentType::ResponseMethods

Defined in:
lib/roda/plugins/response_content_type.rb

Instance Method Summary collapse

Instance Method Details

#content_typeObject

Return the content-type of the response. Will be nil if it has not yet been explicitly set.



62
63
64
# File 'lib/roda/plugins/response_content_type.rb', line 62

def content_type
  @headers[RodaResponseHeaders::CONTENT_TYPE]
end

#content_type=(mime_type) ⇒ Object

Set the content-type of the response. If given a string, it is used directly. If given a symbol, looks up the mime type with the given file extension. If the symbol is not a recognized mime type, raises KeyError.



70
71
72
73
# File 'lib/roda/plugins/response_content_type.rb', line 70

def content_type=(mime_type)
  mime_type = roda_class.opts[:repsonse_content_types].fetch(mime_type) if mime_type.is_a?(Symbol)
  @headers[RodaResponseHeaders::CONTENT_TYPE] = mime_type
end