]> Dogcows Code - chaz/p5-HTTP-AnyUA/blob - t/app.psgi
Version 0.900
[chaz/p5-HTTP-AnyUA] / t / app.psgi
1 # A little plack app for testing HTTP::AnyUA
2
3 # When a request is made, the environment will be sent back to the test which will assert that the
4 # request was made correctly.
5
6 use Plack::Builder;
7 use Util qw(send_env);
8
9 builder {
10
11 mount '/create-document' => sub {
12 my $env = shift;
13 send_env($env);
14 [201, ['Content-Type' => 'text/plain'], ['created document']];
15 };
16
17 mount '/get-document' => sub {
18 my $env = shift;
19 send_env($env);
20 [200, ['Content-Type' => 'text/plain', 'x-foo' => 'bar'], ['this is a document']];
21 };
22
23 mount '/modify-document' => sub {
24 my $env = shift;
25 send_env($env);
26 [204, [], ['']];
27 };
28
29 mount '/foo' => sub {
30 [302, ['Content-Type' => 'text/plain', 'Location' => '/bar'], ['the thing you seek is not here']];
31 };
32 mount '/bar' => sub {
33 [301, ['Content-Type' => 'text/plain', 'Location' => '/baz'], ['not here either']];
34 };
35 mount '/baz' => sub {
36 my $env = shift;
37 send_env($env);
38 [200, ['Content-Type' => 'text/plain'], ['you found it']];
39 };
40
41 mount '/' => sub {
42 [200, ['Content-Type' => 'text/plain'], ['this is a test server']];
43 };
44
45 }
46
This page took 0.034183 seconds and 4 git commands to generate.