Skip to content

Instantly share code, notes, and snippets.

@s1037989
Last active September 17, 2016 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s1037989/e812171b8dc32d280df8938cfd451fc1 to your computer and use it in GitHub Desktop.
Save s1037989/e812171b8dc32d280df8938cfd451fc1 to your computer and use it in GitHub Desktop.
acme
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
BEGIN { unshift @INC, "$FindBin::Bin/../lib" }
use Mojolicious::Commands;
# Start command line interface for application
Mojolicious::Commands->start_app('ACME');
package ACME;
use Mojo::Base 'Mojolicious';
use 5.20.0;
use feature qw(signatures);
no warnings qw(experimental::signatures);
sub startup {
my $self = shift;
$self->plugin('ACME');
$self->secrets(['new_passw0rd', 'old_passw0rd', 'very_old_passw0rd']);
$self->defaults(layout => 'default', title => $self->config('title') || $self->moniker);
my $r = $self->routes;
$r->get('/test' => sub { my $c = shift; $c->delay(sub{ Mojo::IOLoop->next_tick(shift->begin) }, sub { $c->render(text => 'hello world') }) });
}
1;
$ perl script/acme get /test
[Sat Sep 17 00:06:59 2016] [debug] GET "/test"
[Sat Sep 17 00:06:59 2016] [debug] Routing to a callback
[Sat Sep 17 00:06:59 2016] [debug] Rendering template "layouts/default.html.ep"
[Sat Sep 17 00:06:59 2016] [debug] Template "/_menu.html.ep" not found
[Sat Sep 17 00:06:59 2016] [debug] Your secret passphrase needs to be changed
[Sat Sep 17 00:06:59 2016] [debug] 200 OK (0.003848s, 259.875/s)
<!DOCTYPE html>
<!-- http://www.html.am/templates/downloads/preview.cfm?template=layout-templates/2-column-left-menu-header-footer.cfm -->
hello world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment