Last active
August 29, 2015 14:05
-
-
Save gmodecorp/70d0e8ee5da75cb43c56 to your computer and use it in GitHub Desktop.
リクエスト毎の処理
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub dispatch { | |
my $c = shift; | |
# ユーザが指定された処理を、Mouse::Roleにて差し込めるためのHook. | |
$c->INITIALIZE; | |
# 実行するロジック関数を見つける | |
my ($controller,$action) = $c->dispatcher->match( $c ); | |
# 見つからなければ、404 | |
if ( !$controller or !$action ) { | |
$c->not_found; | |
return $c->FINALIZE; | |
} | |
my $controller_obj = $c->dispatcher->controllers->{$controller}; | |
try { | |
# ユーザが指定された処理を、Mouse::Roleにて差し込めるためのHook. | |
$c->PREPARE; | |
# ロジックを実行する。Hookを入れれるようにしている。 | |
$controller_obj->EXECUTE( $c ,$action ); | |
} | |
catch { | |
die $_ unless /^ZE_EXCEPTION_ABORT/; | |
}; | |
unless ( $c->finished ) { | |
# ブラウザーに表示する | |
$c->RENDER(); | |
} | |
$c->FINALIZE(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment