Looking for a way, how to run the same PSGI $app
for multiple requests what aren't defined by the mount prefix
. How to mount
in such screnario? E.g. let say i have in my app.psgi
use Plack::Builder;
my $defaultapp = sub { ... };
my $someapp = sub { ... };
my $otherapp = sub { ... };
builder {
mount '/some' => $someapp; # ok
#and here need something like:
mount "_regex_here" => $otherapp; #???
mount '/' => $defaultapp; #OK - last mount is the "default"
}
E.g., the requests matching
/some/path
- want be handled by the$someapp
(this is OK)/[A-Z]\w+/\w+\.(xxx|yyy|zzz)$
- want be handled by the$otherapp
- any other request want be handled by the
$defaultapp
(Ok too)
This is probably "damm-easy" - but my reading thru of the Plack::Builder doesn't give the answer. (Each mount
in the maual and examples are strict /path
based...)
EDIT: If this isn't possible by the mount
is it possible to solve the above requirement in some clean (read not hackish) way? I don't need change the PATH_INFO
, nor the SCRIPT_NAME
(as URLMap is doing) - just need run the given $otherapp
, for the matched requests.
EDIT2:
To be more clear. The $someapp
and the $otherapp
are already existing applications. Especially the $otherapp
is an complex application what handles every request on its own way - but the requests what "belongs" to the $otherapp
is possible to describe by regex.
I can't use the mount /fixed/prefix
because the $otherapp
creates different urls at runtime, e.g. for example based on the users activity it could create /Abc/xyz.eee
and/or /Zzz/uuu.ddd
etc.. Therefore i can't prefix the $otherapp
as for example:
mount '/other' => $otherapp
Now, want "import" this old-fashinoed $otherapp
to an new PSGI based server and moreover, the $defaultapp
and the $someapp
will do something with the data of the $otherapp
. It sounds complicated, but in the reality it isn't - only need run the $otherapp
based on the requests regex, e.g. something as Apache's SetHandler somehandler *.ext
...