module PlaceOS::Api::Utils::Responders

Defined in:

placeos-rest-api/utilities/responders.cr

Instance Method Summary

Macro Summary

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


[View source]
def render_error(status : HTTP::Status, message : String | Nil, **additional) #

Renders API error messages in a consistent format


[View source]
def restrict_attributes(model, only : Array(String) | Nil = nil, except : Array(String) | Nil = nil, fields : Hash | Nil = nil) : Hash #

Restrict model attributes


[View source]
def save_and_respond(resource, &) #

Shortcut to save a record and render a response

Accepts an optional block to process the entity before response.


[View source]
def save_and_respond(resource) #

Shortcut to save a record and render a response

Accepts an optional block to process the entity before response.


[View source]
def save_and_status(resource) #

Shortcut to save a record and give the correct status


[View source]
def with_fields(model, fields) : Hash #

Merge fields into object


[View source]

Macro Detail

macro render_json(status = :ok, &block) #

Write JSON to the response IO


[View source]