NAME
Toadfarm::Manual::Config - Config file format for Toadfarm
DESCRIPTION
This manual gives in-depth information about the config file format.
Basics
The basic structure is a pure Perl file, which defines a hash-ref:
{
apps => [],
hynotoad => {},
log => {},
paths => {},
plugins => [],
secrets => [],
};
Anything you put before the hash-ref is up to you.
Apps
The "apps" key holds a list of application/config pairs. The application can either be a full path to the application or a class name. The config is either HTTP headers to trigger on, or "Special fields".
The apps are processed in the order they are defined. This means that the first app that match a given rule will receive the request.
{
apps => {
'/usr/local/bin/mojopaste' => {
Host => 'p.thorsen.pm',
config => {
paste_dir => '/some/other/location
},
},
},
...
};
Most keys are used to filter the request based on the HTTP header value. Example header name/values:
'Host' => 'p.thorsen.pm',
'User-Agent' => qr{Mozilla},
'X-Request-Base' => 'http://mydomain.com/whatever',
'X-Remote-IP' => qr{^10\.},
Special fields
Fields that are defined in the list below are special fields.
config => \%hash
This config param will override any config parameters already known in the target application.
Note: These config params are set after startup() is called. (This will hopefully be changed/fixed in future release of Toadfarm)
mount_point => $str
The default mount point is "/". Setting this to "/foo" will only make the application accessible under "http://domain.com/foo".
remote_address => $str|$regex
Used to only accept a given remote_address access.
remote_port => $str|$regex
Used to only accept a given remote_port access.
X-Request-Base => $str
This also sets the request base url when this rule match. This is the same funtionality that is provided by Mojolicious::Plugin::RequestBase.
Additional fields might be added, but they will always be in lower case.
Hypnotoad
{
hypnotoad => {
workers => 7,
listen => ['http://*:8080'],
},
}
See "SETTINGS" in Mojo::Server::Hypnotoad for more options.
Log
It is possible to get Toadfarm to log for all your apps:
{
log => {
file => '/path/to/log/file.log',
level => 'debug', # debug, info, warn, ...
combined => 1,
},
}
The trick here is the "combined" flag. It makes all the apps share the same Mojo::Log object.
Paths
You can specify custom template and public file paths for Toadfarm. This is useful if you want your own error templates or serve other assets from Toadfarm.
{
paths => {
renderer => [ '/my/custom/template/path' ],
static => [ '/my/custom/static/path' ],
},
};
Plugins
It is possible to load plugins into the core of Toadfarm.
{
plugins => [
"Some::Plugin" => @config_arguments,
],
};
Toadfarm comes with two plugins: Toadfarm::Plugin::AccessLog and Toadfarm::Plugin::Reload, but you can also use other plugins from CPAN.
Secrets
Specifying secrets for your app is really important if you are using sesssion.
{
secrets => ['my super secret'],
}
See also "secrets" in Mojolicious.
AUTHOR
Jan Henning Thorsen - jhthorsen@cpan.org