Method: Grape::DSL::InsideRoute#rack_response
- Defined in:
- lib/grape/dsl/inside_route.rb
#rack_response(message, status = 200, headers = { Rack::CONTENT_TYPE => content_type }) ⇒ Object
Creates a Rack response based on the provided message, status, and headers. The content type in the headers is set to the default content type unless provided. The message is HTML-escaped if the content type is ‘text/html’.
Returns: A Rack::Response object containing the specified message, status, and headers.
188 189 190 191 192 |
# File 'lib/grape/dsl/inside_route.rb', line 188 def rack_response(, status = 200, headers = { Rack::CONTENT_TYPE => content_type }) Grape.deprecator.warn('The rack_response method has been deprecated, use error! instead.') = Rack::Utils.escape_html() if headers[Rack::CONTENT_TYPE] == 'text/html' Rack::Response.new(Array.wrap(), Rack::Utils.status_code(status), headers) end |