The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Catalyst::View::Errors::JSON - Standard HTTP Errors Responses in JSON

SYNOPSIS

    package MyApp::View::JSON;

    use Moose;
    extends 'Catalyst::View::Errors::JSON';

    __PACKAGE__->meta->make_immutable;

DESCRIPTION

Used to generate a JSON error response in standard way.

METHODS

This view exposes the follow methods for public use or for a programmer to override to change function.

finalize_message_info

Finalizes the hash of data that is sent to the template handler to make the body of the error response. You can override if you want to change or add to this data.

By default you get an error message that looks like this:

    {
       "info" : {
          "lang" : "en_US",
          "uri" : "http://localhost:5000/"
       },
       "errors" : [
          {
             "title" : "Resource not found",
             "messge" : "The requested resource could not be found but may be available again in the future.",
             "status_code" : 404
          }
       ]
    }

If you're passing extra template args you'll need to override this method to handle things as you wish.

CONFIGURATION

This View exposes the following configuration options

extra_encoder_args

Extra args used to initialize the JSON::MaybeXS object.

default_language

When doing content negotiation if there's no language preferred by the client use this language. Default is en_US.

SEE ALSO

CatalystX::Errors.

AUTHOR

CatalystX::Errors.

COPYRIGHT & LICENSE

CatalystX::Errors.