Class: H2OConfigurator::RedirectHandler
- Inherits:
-
Object
- Object
- H2OConfigurator::RedirectHandler
- Defined in:
- lib/h2o-configurator/handlers/redirect.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/h2o-configurator/handlers/redirect.rb', line 5 def call(env) host_dir = env['HOST_DIR'] path = env['PATH_INFO'] redirect_path = host_dir + path.sub(%r{/$}, '') + '.redirect' if File.exist?(redirect_path) location, status = File.read(redirect_path).split(/\s+/, 2) status = status.to_i [status, {'location' => location}, []] elsif path !~ %r{/$} && File.directory?(host_dir + path) [302, {'location' => path + '/'}, []] else [399, {}, []] end end |