PlackX-Framework

 view release on metacpan or  search on metacpan

lib/PlackX/Framework/Handler.pm  view on Meta::CPAN

    # if app_base is specified, use URLMap
    if (my $app_base = $class->app_base) {
      require Plack::App::URLMap;
      my $mapper = Plack::App::URLMap->new;
      $mapper->map($app_base => $main_app);
      $mapper->map('/'       => $file_app) if $file_app;
      return $mapper->to_app;
    }

    # Static file app with no app_base, so try one, try the other if it's 404
    # (basically our own cascade whereas we could use Plack::App::Cascade).
    # We prefer to serve the app's 404 page if the file app also returns 404
    # because it is easier to customize the 404 page with PXF.
    # Add a later date we might add a feature to intercept all 4xx and 5xx
    # error codes at the last possible moment and render a user-defined page.
    return sub ($env) {
      my $main_resp = $main_app->($env);
      return $main_resp if ref $main_resp and $main_resp->[0] != 404;
      my $file_resp = $file_app->($env);
      return $file_resp if ref $file_resp and $file_resp->[0] != 404;
      return $main_resp;



( run in 2.332 seconds using v1.01-cache-2.11-cpan-2398b32b56e )