| 1 | # -*- Mode: Perl; indent-tabs-mode: nil; -*- | ||
| 2 | |||
| 3 | package Wombat::Core::HostValve; | ||
| 4 | |||
| 5 | use base qw(Wombat::Valve::ValveBase); | ||
| 6 | use fields qw(); | ||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | |||
| 10 | use Servlet::Util::Exception (); | ||
| 11 | |||
| 12 | # public methods | ||
| 13 | |||
| 14 | sub getName { return 'HostValve' } | ||
| 15 | |||
| 16 | sub invoke { | ||
| 17 | my $self = shift; | ||
| 18 | my $request = shift; | ||
| 19 | my $response = shift; | ||
| 20 | |||
| 21 | my $host = $self->getContainer(); | ||
| 22 | my $application = $host->map($request); | ||
| 23 | unless ($application) { | ||
| 24 | my $status = Servlet::Http::HttpServletResponse::SC_NOT_FOUND; | ||
| 25 | $response->getResponse()->sendError($status); | ||
| 26 | |||
| 27 | $host->handleError($request, $response); | ||
| 28 | return 1; | ||
| 29 | } | ||
| 30 | |||
| 31 | $application->invoke($request, $response); | ||
| 32 | |||
| 33 | return 1; | ||
| 34 | } | ||
| 35 | |||
| 36 | 1; | ||
| 37 | __END__ |