This I'm trying for transfer my current Apache/Modperl site to Starman, and need build app.psgi with different handlers for different file extensions. Somthing as in the Apache:
<LocationMatch "(\.m|\.mh|\/)$">
SetHandler perl-script
PerlHandler MyApp::Mhandler
</LocationMatch>
<LocationMatch "(\.p|\.ph)$">
SetHandler perl-script
PerlHandler MyApp::Phandler
</LocationMatch>
Now I have:
#app for handle .m and .mh
my $Mapp = Some::PSGI->handler( sub {
...
});
#app for handling .p and .ph
my $Papp = SomeOther::PSGI->handler( sub {
...
});
but how to use the builder?
builder {
#any extension what is not .m .mh .p .ph - handle as static
#but, only when the request have any extension
enable "Plack::Middleware::Static",
path => __what here__, ???
root => "/my/doc/root";
#and what here to achieve the following "rules".
#??? $Papp
#default $Mapp
};
Needed "rules":
- if the request does not have any extension, or the request ends with '/'
- should be handled with
$Mapp
- should be handled with
- if the request ends with some extension, then
.m
and.mh
should be handled by$Mapp
.p
and.ph
should be handled by$Papp
- all other files with extensions (like .css .js .pdf .jpg ...) should be handled as static.
Sure, will be much easier put every static file into some tree, but the current app is given and now i only want move it into Startman, refactoring - later.