Commit | Line | Data |
---|---|---|
4ed4fb42 | 1 | package Web::Dispatch::Node; |
2 | ||
3 | use Moo; | |
4 | ||
5 | with 'Web::Dispatch::ToApp'; | |
6 | ||
7 | for (qw(match run)) { | |
8 | has "_${_}" => (is => 'ro', required => 1, init_arg => $_); | |
9 | } | |
10 | ||
11 | sub call { | |
12 | my ($self, $env) = @_; | |
13 | if (my ($env_delta, @match) = $self->_match->($env)) { | |
14 | $self->_curry(@match)->({ %$env, %$env_delta }); | |
15 | } else { | |
16 | () | |
17 | } | |
18 | } | |
19 | ||
20 | sub _curry { | |
21 | my ($self, @args) = @_; | |
22 | my $run = $self->_run; | |
23 | sub { $run->(@args, $_[0]) }; | |
24 | } | |
25 | ||
26 | 1; |