Usage:
This is used for a successful response and no payload is desired.
Response.ok(conn)
Returns Plug.Conn.t()
with a status of 200
and an empty payload.
Usage:
This is used for a successful response.
Response.ok(conn, %{records: _, current_page: _, total_pages: _, total_records: _}, fields)
Returns Plug.Conn.t()
with a status of 200
and a payload of
%{
"current_page" => _,
"records" => _,
"total_pages" => _,
"total_records" => _
}
Usage:
This is used for a successful created response.
Response.created(conn, result, fields)
Returns Plug.Conn.t()
with a status of 201
and the result passed in as the payload.
Usage:
This is used for an accepted response. Normally used to signify that the request was accepted, but might not have finished processing.
Response.accepted(conn)
Returns Plug.Conn.t()
with a status of 202
and an empty payload.
Usage:
This is used for an accepted response. Normally used to signify that the request was accepted, but might not have finished processing.
Response.accepted(conn, details)
Returns Plug.Conn.t()
with a status of 202
and the details passed in as the payload.
Usage:
This is used for an accepted response. Normally used to signify that the request was accepted, but might not have finished processing.
Response.accepted(conn, %{license_plate: _, state: _}, fields)
Returns Plug.Conn.t()
with a status of 202
and a payload of
%{
"license_plate" => _,
"state" => _
}
Usage:
This is used for a no_content response. Normally used when deleting.
Response.no_content(conn)
Returns Plug.Conn.t()
with a status of 204
and an empty payload.
Usage:
This is used to signify a bad request.
Response.bad_request(conn)
Returns Plug.Conn.t()
with a status of 400
and a payload of
%{"errors" => {code: :bad_request, description: "Bad request.", field: nil}
Usage:
This is used to signify a bad request and takes either binary()
or Ecto.Changeset.t()
.
Response.bad_request(conn, message | changeset)
Returns Plug.Conn.t()
with a status of 400
and a payload dependent upon the provided data.
Usage:
This is used to signify an unauthorized request.
Response.unauthorized(conn)
Returns Plug.Conn.t()
with a status of 401
and a payload of
%{"errors" => [{code: :unauthorized, description: "Must include valid Authorization credentials", field: nil}]}
Usage:
This is used to signify a forbidden response.
Response.forbidden(conn)
Returns Plug.Conn.t()
with a status of 403
and a payload of
%{"errors" => [{code: :forbidden, description: "This action is forbidden.", field: nil}]}
Usage:
This is used to signify a not found response.
Response.not_found(conn)
Returns Plug.Conn.t()
with a status of 404
and a payload of
%{"errors" => [{code: :not_found, description: "The resource was not found.", field: nil}]}
Usage:
This is used to signify a conflicting response.
Response.conflict(conn, description)
Returns Plug.Conn.t()
with a status of 409
and a payload of
%{"errors" => [{code: :conflict, description: description, field: nil}]}
Usage:
This is used to signify a base unprocessable_entity response.
Response.unprocessable_entity(conn)
Returns Plug.Conn.t()
with a status of 422
and a payload of
%{"errors" => [{code: :unprocessable_entity, description: "Unable to process change.", field: nil}]}
Usage:
This is used to signify an internal_server_error response. Use in the rare case that you want to throw a 500
.
Response.internal_server_error(conn, message)
Returns Plug.Conn.t()
with a status of 500
and a payload of
%{"errors" => [message]}