File: sub-dispatch-env.t

package info (click to toggle)
libweb-simple-perl 0.033-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 380 kB
  • sloc: perl: 1,622; makefile: 7
file content (26 lines) | stat: -rw-r--r-- 553 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use strictures 1;
use Test::More 0.88;

{
  package TestApp;

  use Web::Simple;

  sub dispatch_request {
    sub (/foo/...) {
      sub (GET) { [ 200, [], [ $_[PSGI_ENV]->{PATH_INFO} ] ] }
    },
    sub (POST) { [ 200, [], [ $_[PSGI_ENV]->{PATH_INFO} ] ] }
  }
}

my $app = TestApp->new->to_psgi_app;

my $call = sub { $app->({
  SCRIPT_NAME => '/base', PATH_INFO => '/foo/bar', REQUEST_METHOD => shift
})->[2]->[0] };

is($call->('GET'), '/bar', 'recursive strip ok');
is($call->('POST'), '/foo/bar', 'later dispatchers unaffected');

done_testing;