This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Plack::Builder; | |
use Plack::App::File; | |
sub slashify_if (&) { | |
my $code = shift; | |
return sub { | |
my $app = shift; | |
return sub { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $root = '.'; | |
my @indexes = qw(index.html); | |
use strict; | |
use warnings; | |
use Plack::App::File; | |
use Plack::App::Cascade; | |
sub directory_indexes { | |
my ($root, @indexes) = @_; | |
my $file = Plack::App::File->new(root => $root)->to_app; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ur old/Parser.pm new/Parser.pm | |
--- old/Parser.pm 2010-06-15 13:57:43.000000000 -0500 | |
+++ new/Parser.pm 2011-03-01 13:44:02.000000000 -0600 | |
@@ -260,6 +260,12 @@ | |
unless $http and $http =~ /^HTTP\/(\d+)\.(\d+)$/i; | |
($major,$minor) = ($1,$2); | |
die 'HTTP requests not allowed' unless $self->{request}; | |
+ | |
+ # If the requested uri was a path instead of a full uri, we need to tell URI that we don't | |
+ # know the scheme, otherwise it will interpret paths that start with a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cpanm (App::cpanminus) 1.1005 on perl 5.012002 built for i686-linux-thread-multi | |
Work directory is /home/hdp/.cpanm/work/1297880895.3215 | |
You have make /usr/bin/make | |
You have LWP 5.837 | |
You have /bin/tar: tar (GNU tar) 1.23 | |
Copyright (C) 2010 Free Software Foundation, Inc. | |
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. | |
This is free software: you are free to change and redistribute it. | |
There is NO WARRANTY, to the extent permitted by law. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sort of a mini-global | |
my $c; | |
my $tx = Text::Xslate->new( | |
function => { | |
text_field => sub { $link_to->($c, @_) }, | |
... | |
}, | |
..., | |
); | |
# called as $render->($c, @other_render_args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* vim: ts=2 sts=2 sw=2: | |
*) | |
#directory "+extlib" | |
#load "extLib.cma" | |
type mark = X | O | |
type space = | |
Empty | |
| Full of mark |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Cell() | |
case class Space() extends Cell { | |
override def toString() = " " | |
} | |
case class X() extends Cell { | |
override def toString() = "X" | |
} | |
case class O() extends Cell { | |
override def toString() = "O" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Plack::App::TemplateToolkit; | |
use Plack::App::File; | |
builder { | |
mount '/static' => Plack::App::File->new( | |
root => '/path/to/static/files', | |
)->to_app; | |
mount '/tt' => Plack::App::TemplateToolkit->new( | |
root => '/path/to/templates', | |
extension => '.tt', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$app = ...; | |
if (my $map = $self->config->proxy_map) { | |
my $urlmap = Plack::App::URLMap->new; | |
for my $type (keys %$map) { | |
my ($prefix, $remote, $headers) = | |
@{$map->{$type}}{qw(path_prefix remote headers)}; | |
$headers ||= {}; | |
my $proxy = Plack::App::Proxy->new( | |
remote => $remote, | |
preserve_host_header => 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Plack::App::Cascade; | |
my $app = Plack::App::Cascade->new; | |
$app->add(sub { | |
my $env = shift; | |
return sub { | |
my $respond = shift; | |
my $writer = $respond->([404, []]); | |
$writer->write("boo"); | |
$writer->close; |