Ravn::Tactical::

App class

Ravn::Tactical::App - the Rack container for Ravn-Tactical services.

Public Instance Methods

bad_request( request, reason="Invalid request body" )
bad_request_response( request, reason="Invalid request body" )

Halt with a 400 BAD REQUEST response, building a diagnostic body with the given reason.

    # File lib/ravn/tactical/app.rb
213 def bad_request_response( request, reason="Invalid request body" )
214     description = "Bad request: %s" % [ reason ]
215     request.halt( [400, {'Content-Type' => 'text/plain'}, [description]] )
216 end
Also aliased as: bad_request
error_response_body( error_type, error_detail, *backtrace )

Return a Hash suitable for use as an error response body that includes the given error_type, error_detail and backtrace in development mode. In production mode, this returns a generic error message to avoid information exposure.

    # File lib/ravn/tactical/app.rb
153 def error_response_body( error_type, error_detail, *backtrace )
154     if Ravn::Tactical.production?
155         body = { error: "An error occurred." }
156     else
157         body = {
158             error: "%s while servicing the request" % [ error_type ],
159             detail: error_detail,
160         }
161         body[ :backtrace ] = backtrace.flatten unless backtrace.empty?
162     end
163 
164     self.log.debug "Returning error body: %p" % [ body ]
165     return body
166 end