Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added another request rewriting example to the cookbook

  • Loading branch information...
commit 4d6555a19da2c3e6788b1228cb7f04539806e9b0 1 parent 6f11a0d
@kraih authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/Mojolicious/Guides/Cookbook.pod
View
10 lib/Mojolicious/Guides/Cookbook.pod
@@ -221,6 +221,16 @@ you can use a C<before_dispatch> hook to rewrite incoming requests.
if $self->req->headers->header('X-Forwarded-Protocol') eq 'https';
});
+Since reverse proxies generally don't pass along information about path
+prefixes your application might be deployed under, rewriting the base path of
+incoming requests is also quite common.
+
+ app->hook(before_dispatch => sub {
+ my $self = shift;
+ push @{$self->req->url->base->path->parts},
+ shift @{$self->req->url->path->parts};
+ }) if app->mode eq 'production';
+
=head2 Application embedding
From time to time you might want to reuse parts of L<Mojolicious> applications
Please sign in to comment.
Something went wrong with that request. Please try again.