Adding reverse proxy support.

This commit is contained in:
sergiotarxz 2022-11-15 23:57:20 +01:00
parent ae16dd4b6b
commit 20da362510
1 changed files with 26 additions and 21 deletions

View File

@ -7,21 +7,26 @@ use Mojo::Base 'Mojolicious', -signatures;
# This method will run once at server start # This method will run once at server start
sub startup ($self) { sub startup ($self) {
my $metrics = BurguillosInfo::Controller::Metrics->new; my $metrics = BurguillosInfo::Controller::Metrics->new;
$self->hook(around_dispatch => sub { $self->hook(
around_dispatch => sub {
my $next = shift; my $next = shift;
my $c = shift; my $c = shift;
$metrics->request($c); $metrics->request($c);
if ( defined $next ) { if ( defined $next ) {
$next->(); $next->();
} }
}); }
);
my $config = $self->plugin('JSONConfig'); my $config = $self->plugin('JSONConfig');
$self->config(hypnotoad => {listen => ['http://localhost:3000']}); $self->config(
hypnotoad => { proxy => 1, listen => ['http://localhost:3000'] } );
# Router # Router
my $r = $self->routes; my $r = $self->routes;
# Normal route to controller # Normal route to controller
$r->get('/')->to('Page#index'); $r->get('/')->to('Page#index');
# $r->get('/:post')->to('Page#post'); # $r->get('/:post')->to('Page#post');
$r->get('/<:category>.rss')->to('Page#category_rss'); $r->get('/<:category>.rss')->to('Page#category_rss');
$r->get('/:category')->to('Page#category'); $r->get('/:category')->to('Page#category');