Questo sto cercando di trasferire il mio attuale sito Apache/Modperl su Starman e ho bisogno di creare app.psgi con diversi gestori per diverse estensioni di file. Somthing come nel Apache:Conversione di Modperl config in Plack - esecuzione di diversi gestori per estensione file
<LocationMatch "(\.m|\.mh|\/)$">
SetHandler perl-script
PerlHandler MyApp::Mhandler
</LocationMatch>
<LocationMatch "(\.p|\.ph)$">
SetHandler perl-script
PerlHandler MyApp::Phandler
</LocationMatch>
Ora ho:
#app for handle .m and .mh
my $Mapp = Some::PSGI->handler(sub {
...
});
#app for handling .p and .ph
my $Papp = SomeOther::PSGI->handler(sub {
...
});
ma come utilizzare il costruttore?
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
};
necessarie "regole":
- non se la richiesta fa ha alcuna estensione o la richiesta termina con '/'
- deve essere maneggiato con
$Mapp
- deve essere maneggiato con
- se la richiesta termina con qualche estensione, quindi
.m
e.mh
devono essere gestite dal$Mapp
.p
e.ph
devono essere gestite dal$Papp
- tutti gli altri file con le estensioni (come css js .pdf .jpg ...) devono essere trattati come statica.
Certo, sarà molto più facile mettere ogni file statico in qualche albero, ma l'applicazione corrente è data e ora voglio solo spostarlo in Startman, refactoring - in seguito.
eh! Andando a provare a capire questo. :) – kobame
ma SÌ! Il trucco principale è usare un "sub" nel percorso per lo statico e raggruppare due app in una per decisione. BTW, mai usato nessun legame ancora ..;) THANX molto !!! :) – kobame