module Roda::RodaPlugins::ResponseContentType::ResponseMethods

  1. lib/roda/plugins/response_content_type.rb

Methods

Public Instance

  1. content_type
  2. content_type=

Public Instance methods

content_type()

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

[show source]
   # File lib/roda/plugins/response_content_type.rb
66 def content_type
67   @headers[RodaResponseHeaders::CONTENT_TYPE]
68 end
content_type=(mime_type)

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.

[show source]
   # File lib/roda/plugins/response_content_type.rb
74 def content_type=(mime_type)
75   mime_type = roda_class.response_content_types.fetch(mime_type) if mime_type.is_a?(Symbol)
76   @headers[RodaResponseHeaders::CONTENT_TYPE] = mime_type
77 end