NAME
HTTP::Throwable::JSONFactory - Throw exceptions with JSON bodies
VERSION
version 0.002
SYNOPSIS
use HTTP::Throwable::JSONFactory qw(http_throw);
http_throw(Gone => {
payload => {
error => "You won't find what you're looking for here",
},
});
OVERVIEW
This subclass of HTTP::Throwable::Factory arranges for each built/thrown exception to consume the HTTP::Throwable::Role::JSONBody role, which will generate HTTP responses with an application/json
content type and encode the (optional) provided payload using JSON::MaybeXS.
The payload
attribute passed to http_throw
or http_exception
should be anything allowed by "encode_json" in JSON (hashref, arrayref, etc).
AUTHOR
Matthew Horsfall <wolfsage@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Matthew Horsfall.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.