33 lines
675 B
Perl
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;
|