我习惯于在Apache httpd.conf中为不同的目录设置别名。例如,下面的代码适用于我
Alias /lib /path/to/lib然后,无论应用程序路径是什么,我都可以包含诸如<script src="/lib/jquery/plugin/funky.js"></script>之类的路径。
我正在尝试Starman (以及其他PSGI服务器,如HTTP::Server::PSGI),但找不到任何方法来设置目录的别名等配置参数。
这可以做到吗?多么?
发布于 2011-03-18 04:31:40
这可以通过使用Plack::Middleware::Static轻松完成。
use Plack::Builder;
builder {
enable "Static", path => sub { s!^/lib/!! }, root => "/path/to/lib/";
$app;
};您将从"/path/to/lib/foo.js“加载"/lib/foo.js”。这应该适用于Starman和任何PSGI支持的web服务器。
有关更多信息,请访问the online documenetation。
https://stackoverflow.com/questions/5215460
复制相似问题