Mojolicious::Plugin::Notifications::JSON - Event Notification in JSON
# Register the engine plugin Notifications => { JSON => 1 }; # In the controller $c->render(json => $c->notifications(json => $json));
This plugin is a simple notification engine for JSON.
If it does not suit your needs, you can easily write your own engine.
Mojolicious::Plugin::Notifications::JSON inherits all methods from Mojolicious::Plugin and implements the following new one.
plugin Notifications => { JSON => { key => 'notes' } };
Called when registering the main plugin. All parameters under the key JSON are passed to the registration.
JSON
Accepts the following parameters:
Define the attribute name of the notification array. Defaults to notifications.
notifications
See the base notify helper.
$c->render(json => $c->notifications(json => $json)); $c->render(json => $c->notifications(json => $json, key => 'notes'));
Merge notifications into your JSON response.
In case JSON is an object, it will inject an attribute that points to an array reference containing the notifications. If the JSON is an array, an object is appended with one attribute that points to an array reference containing the notifications. If the JSON is empty, an object will be created with one attribute that points to an array reference containing the notifications.
If the JSON is not of one of the descripted types, it's returned unaltered.
The name of the attribute can either be given on registration or by passing a parameter for key. The name defaults to notifications.
key
https://github.com/Akron/Mojolicious-Plugin-Notifications
Copyright (C) 2014, Nils Diewald.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
To install Mojolicious::Plugin::Notifications, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Notifications
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Notifications
For more information on module installation, please visit the detailed CPAN module installation guide.