I really like where maru is going, and it is so much simpler than phoenix for APIs.
These changes add defaults for standard HTTP status codes for maru's built-in exception types (InvalidFormat, Validation, NotFound, and MethodNotAllowed). the :plug_status field is used by the Plug.Exception protocol (https://hexdocs.pm/plug/Plug.Exception.html) to map exception types to HTTP status codes. Plug.Exception falls back to 500 if the field doesn't exist and the exception type doesn't implement the exception protocol. This allows you to do the following:
rescue_from :all, as: e do
conn
|> put_status(Plug.Exception.status(e))
|> text("Request Failed")
end
The status codes can be overridden at raise time, but these defaults seemed sensible for the built-in exception types.
I really like where maru is going, and it is so much simpler than phoenix for APIs.
These changes add defaults for standard HTTP status codes for maru's built-in exception types (
InvalidFormat
,Validation
,NotFound
, andMethodNotAllowed
). the:plug_status
field is used by thePlug.Exception
protocol (https://hexdocs.pm/plug/Plug.Exception.html) to map exception types to HTTP status codes.Plug.Exception
falls back to 500 if the field doesn't exist and the exception type doesn't implement the exception protocol. This allows you to do the following:The status codes can be overridden at raise time, but these defaults seemed sensible for the built-in exception types.