Skip to content
Newer
Older
100644 67 lines (46 sloc) 1.77 KB
f518bd1 @jhthorsen Released version 0.2
jhthorsen authored Nov 4, 2015
1 NAME
2 Mojolicious::Plugin::RequestBase - Support setting base in frontend
3 proxy
4
5 SYNOPSIS
6 Frontend proxy
7 The "X-Request-Base" header must be set in the frontend proxy.
8
9 # nxinx
10 proxy_set_header X-Request-Base "https://example.com/myapp";
11
12 Application
13 This plugin will read the "X-Request-Base" header.
14
15 # Mojolicious
16 $app->plugin("RequestBase");
17
18 # Mojolicious::Lite
19 plugin "RequestBase";
20
21 Controller
22 URL generating helpers, such as url_for will create the correct URL
23 using the base URL from "X-Request-Base".
24
25 Here are example with "X-Request-Base" set to
26 "https://example.com/myapp" and a request sent to Request to
27 "https://example.com/myapp/foo":
28
29 # /myapp/foo
30 $c->url_for;
31
32 # https://example.com/myapp/foo
33 $c->url_for->to_abs;
34
35 # https://example.com/myapp/some/path
36 $c->url_for("/some/path")->to_abs;
37
38 # https://example.com/foo (Probably not what you want)
39 $c->req->url->to_abs;
40
41 DESCRIPTION
42 Simple plugin to support Request Base header. Just load it and set
43 X-Request-Base in your Frontend Proxy. For instance, if you are using
44 nginx you could use it like this:
45
46 proxy_set_header X-Request-Base 'https://example.com/myapp';
47
48 METHODS
49 Mojolicious::Plugin::RequestBase inherits all methods from
50 Mojolicious::Plugin and implements the following new ones.
51
52 register
53 $plugin->register;
54
55 Register plugin in Mojolicious application.
56
57 SEE ALSO
58 Catalyst::TraitFor::Request::ProxyBase, Mojolicious,
59 Mojolicious::Guides, <http://mojolicio.us>.
60
61 COPYRIGHT AND LICENSE
62 Copyright (C) 2011, Marcus Ramberg.
63
64 This program is free software, you can redistribute it and/or modify it
65 under the terms of the Artistic License version 2.0.
66
Something went wrong with that request. Please try again.