| 1 | # $Id: /mirror/gungho/lib/Gungho/Handler/Inline.pm 8911 2007-11-12T01:12:09.994728Z lestrrat $ | ||
| 2 | # | ||
| 3 | # Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp> | ||
| 4 | # Copyright (c) 2007 Kazuho Oku | ||
| 5 | # All rights reserved. | ||
| 6 | |||
| 7 | package Gungho::Handler::Inline; | ||
| 8 | use strict; | ||
| 9 | use warnings; | ||
| 10 | use base qw(Gungho::Handler); | ||
| 11 | use Gungho::Request; | ||
| 12 | |||
| 13 | __PACKAGE__->mk_accessors($_) for qw(callback); | ||
| 14 | |||
| 15 | |||
| 16 | sub setup { | ||
| 17 | my $self = shift; | ||
| 18 | my $callback = $self->config->{callback}; | ||
| 19 | die "``callback'' not supplied\n" unless ref $callback eq 'CODE'; | ||
| 20 | $self->callback($callback); | ||
| 21 | $self->next::method(@_); | ||
| 22 | } | ||
| 23 | |||
| 24 | sub handle_response { | ||
| 25 | my ($self, $c, $req, $res) = @_; | ||
| 26 | |||
| 27 | my @args = ( | ||
| 28 | Class::Inspector->loaded('Gungho::Inline') && | ||
| 29 | &Gungho::Inline::OLD_PARAMETER_LIST ? | ||
| 30 | ($req, $res, $c, $self) : | ||
| 31 | ($self, $c, $req, $res) | ||
| 32 | ); | ||
| 33 | $self->callback->(@args); | ||
| 34 | } | ||
| 35 | |||
| 36 | 1; | ||
| 37 | |||
| 38 | __END__ |