NAME

Toadfarm::Starter - DSL for defining toadfarm applications

DESCRIPTION

Toadfarm::Starter is a module that export sugar for defining your Toadfarm apps. The result is an executable that you can run instead of the toadfarm executable.

This package and the DSL is EXPERIMENTAL.

SYNOPSIS

use Toadfarm::Starter;

logging {
  combined => 1,
  file     => "/var/log/toadfarm/app.log",
  level    => "info",
};

mount "MyApp" => {"Host" => "myapp.example.com"};
mount "Some::Other::App" => {"Host" => "example.com", mount_point => "/other"};

plugin "Toadfarm::Plugin::AccessLog";

secrets "super-secret";

start;

FUNCTIONS

These functions are exported to the caller namespace by default. See "SYNOPSIS" for example usage.

app

$app = app;

Used to fetch the Toadfarm instance that the rest of the functions below are using.

logging

logging {
  combined => 0,
  path     => "/path/to/log/file.log",
  level    => "info",
};

Used to set up Mojo::Log. See "path" in Mojo::Log and "level" in Mojo::Log for details on the accepted values. combined can be set to true to make all the mounted apps use the same Mojo::Log object.

mount

mount "/path/to/mojo-app" => \%config;
mount "My::Mojo::App" => \%config;
mount "My::Mojo::App";

This function will mount a Mojolicious application, much like Mojolicious::Plugin::Mount does, but has more options. See "Apps" in Toadfarm::Manual::Config for more details.

An application without %config is considered to be a "catch all" application, meaning that it will get all the requests that does not match any of the above.

plugin

plugin "My::Mojo::Plugin" => \%config;
plugin "AccessLog";

Used to load a Mojolicious::Plugin. In addition to the default Mojolicious::Plugin namespace, this application will also search in the Toadfarm::Plugin:: namespace.

secrets

secrets @str;

Used to set application secrets. A random secret will be used if none is specified.

start

start;
start \@listen, %config;
start %config;

Used to start the application. Both @listen and %config are optional, but will be used to specify the Mojo::Server::Hypnotoad config.

These three examples does the same thing:

# 1.
start proxy => 1;
# 2.
start ["http://*:8080"], {proxy => 1};
# 3.
start {listen => ["http://*:8080"], proxy => 1};

METHODS

import

Will export the sugar defined under "FUNCTIONS".

COPYRIGHT AND LICENSE

Copyright (C) 2014, Jan Henning Thorsen

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org