23 lines
500 B
Ruby
23 lines
500 B
Ruby
module LifePex::Systems::ApiResponse
|
|
def api_response(any)
|
|
content_type 'application/json'
|
|
any.to_json
|
|
end
|
|
|
|
def api_response_entity(message = nil, entity_type = nil, entity = nil, **more)
|
|
api_response({
|
|
"message" => message,
|
|
"entity_type" => entity_type,
|
|
entity_type => entity,
|
|
**more,
|
|
}.compact)
|
|
end
|
|
|
|
def api_error(status = 500, message = "Internal error", **more)
|
|
halt(status, {
|
|
message => message,
|
|
**more,
|
|
}.to_json)
|
|
end
|
|
end
|