module PlaceOS::Api::Utils::Responders
Defined in:
placeos-rest-api/utilities/responders.crInstance Method Summary
-
#handle_execute_error(error : Driver::Proxy::RemoteDriver::Error, respond : Bool = true)
RemoteDriver Execute error responder
-
#render_error(status : HTTP::Status, message : String | Nil, **additional)
Renders API error messages in a consistent format
-
#restrict_attributes(model, only : Array(String) | Nil = nil, except : Array(String) | Nil = nil, fields : Hash | Nil = nil) : Hash
Restrict model attributes
-
#save_and_respond(resource, &)
Shortcut to save a record and render a response
-
#save_and_respond(resource)
Shortcut to save a record and render a response
-
#save_and_status(resource)
Shortcut to save a record and give the correct status
-
#with_fields(model, fields) : Hash
Merge fields into object
Macro Summary
-
render_json(status = :ok, &block)
Write JSON to the response IO
Instance Method Detail
def handle_execute_error(error : Driver::Proxy::RemoteDriver::Error, respond : Bool = true)
#
RemoteDriver Execute error responder
With respond = true, method acts as a logging function
def render_error(status : HTTP::Status, message : String | Nil, **additional)
#
Renders API error messages in a consistent format
def restrict_attributes(model, only : Array(String) | Nil = nil, except : Array(String) | Nil = nil, fields : Hash | Nil = nil) : Hash
#
Restrict model attributes
def save_and_respond(resource, &)
#
Shortcut to save a record and render a response
Accepts an optional block to process the entity before response.
def save_and_respond(resource)
#
Shortcut to save a record and render a response
Accepts an optional block to process the entity before response.