webhook2ntfy/lib/Webhook2Ntfy.pm
Dominik Meyer f20a2919d3
All checks were successful
continuous-integration/drone/push Build is passing
ADD: initial commit
2024-03-06 08:34:02 +01:00

33 lines
675 B
Perl

package Webhook2Ntfy;
use Mojo::Base 'Mojolicious', -signatures;
# This method will run once at server start
sub startup ($self) {
# Configure the application
$self->secrets($ENV{SECRETS});
my $webhook = $ENV{WEBHOOK_PATH};
if (!$webhook || length($webhook) == 0 )
{
$self->log->fatal("no webhook provided in WEBHOOK_PATH");
exit(-1);
}
elsif (length($webhook) < 20)
{
$self->log->fatal("please provide a more complex webhook path in WEBHOOK_PATH");
exit(-1);
}
$self->log->info("using webhook path: " . $webhook);
# Router
my $r = $self->routes;
# Normal route to controller
$r->post($webhook)->to('Webhook#call');
}
1;