NAME
Mojolicious::Plugin::AWS::SNS - Publish to AWS SNS topic
SYNOPSIS
# Mojolicious
$self->plugin('Mojolicious::Plugin::AWS::SNS');
# Mojolicious::Lite
plugin 'Mojolicious::Plugin::AWS::SNS';
$c->sns_publish(
region => 'us-east-2',
topic => $topic_arn,
subject => 'my subject',
message => {default => 'my message'},
access_key => $access_key,
secret => $secret_key
)->then(
sub {
my $tx = shift;
say $tx->res->json('/PublishResponse/PublishResult/MessageId');
}
);
DESCRIPTION
LMojolicious::Plugin::AWS::SNS> is a Mojolicious plugin for publishing to Amazon Web Service's Simple Notification Service.
CAVEAT
This module is alpha quality. This means that its interface will likely change in backward-incompatible ways, that its performance is unreliable, and that the code quality is only meant as a proof-of-concept. Its use is discouraged except for experimental, non-production deployments.
HELPERS
Mojolicious::Plugin::AWS::SNS implements the following helpers.
sns_publish
$c->sns_publish(
region => $aws_region,
access_key => $access_key,
secret_key => $secret_key,
topic => $topic_arn,
subject => 'Automatic Message',
message => {
default => 'default message',
https => 'this is sent to your HTTPS endpoint'
}
)->then(
sub {
my $tx = shift;
say STDERR "Response: " . $tx->res->body;
}
)->wait;
Returns a Mojo::Promise object that contains the results of the AWS SNS Publish command:
use Data::Dumper;
say Dumper $tx->res->json;
{
'PublishResponse' => {
'PublishResult' => {
'MessageId' => '5d9ab65c-0363-5a41-dba1-f1bb241d9132',
'SequenceNumber' => undef
},
'ResponseMetadata' => {
'RequestId' => '3b8c6c31-a7eb-b5d6-58d4-df0fc3b80192'
}
}
}
METHODS
Mojolicious::Plugin::AWS::SNS inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register(Mojolicious->new);
Register plugin in Mojolicious application.
AUTHOR
Scott Wiersdorf, <scott@perlcode.org>
SPONSORS
COPYRIGHT AND LICENSE
Copyright (C) 2019, Scott Wiersdorf.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.