app/helpers/base.rb
# If you want to match against the HTTP_ACCEPT value.
#
# @example
#   # HTTP_ACCEPT=application/xml
#   on accept("application/xml") do
#     # automatically set to application/xml.
#     res.write res["Content-Type"]
#   end
If you want to match against the HTTP_ACCEPT value.
If you want to match against the HTTP_ACCEPT value .
def accept(mimetype)
    lambda do
      accept = String(env["HTTP_ACCEPT"]).split(",")
      if accept.any? { |s| s.strip == mimetype }
        res["Content-Type"] = mimetype
      end
    end
  end
def accept ( mimetype ) lambda do accept = String ( env [ "HTTP_ACCEPT" ] ) . split ( "," ) if accept . any? { | s | s . strip == mimetype } res [ "Content-Type" ] = mimetype end end end
If you want to match against the HTTP_ACCEPT value.
If you want to match against the HTTP_ACCEPT value .
mimetype
<not_specific>
example
HTTP_ACCEPT=application/xml on accept("application/xml") do # automatically set to application/xml. res.write res["Content-Type"] end
HTTP_ACCEPT = application / xml on accept ( " application / xml " ) do # automatically set to application / xml . res . write res [ " Content - Type " ] end