Rack 中貌似没有PATH这个东东。楼主的意思是系统环境变量里的PATH么?
Rack 中 env['SCRIPT_NAME']的解释是:
## <tt>SCRIPT_NAME</tt>:: The initial portion of the request
## URL's "path" that corresponds to the
## application object, so that the
## application knows its virtual
## "location". This may be an empty
## string, if the application corresponds
## to the "root" of the server.
PEP333 也是这么说的。还有一个解释是
the “base” of the URL, representing the root of the application.`
觉得这就是 App 启动后,URL 里的前缀。也可以说是项目的挂载路径吧。
比如,如果 config.ru 中为
run MyApp::Application
- 默认启动,首页地址为 http://locahost:3000/ ,
env['SCRIPT_NAME'] 的值为空 。
- 启动时加上
--prefix=/p1参数(比如 thin start --prefix=/p1),首页地址为 http://localhost:3000/p1/ ,env['SCRIPT_NAME'] 的值为 '/p1'。
如果在config.ru中,写
map '/p2' do
run MyApp::Application
end
- 默认启动,首页地址为 http://localhost:3000/p2/,那么
env['SCRIPT_NAME'] 的值就是 '/p2' 。
- 如果以类似
thin start --prefix=/p1 命令启动,首页地址为 http://localhost:3000/p1/p2/ ,那么 env['SCRIPT_NAME'] 的值就是 '/p1/p2' 。