Sha256: e889d783841f1496105d448826a6df998c2447dee9e49e7e4d5d74933a58b360
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
class Usher module Interface class Rack # Route specific for Rack with redirection support built in. class Route < Usher::Route # Redirect route to some other path. def redirect(path, status = 302) unless (300..399).include?(status) raise ArgumentError, "Status has to be an integer between 300 and 399" end to { |env| params = env[Usher::Interface::Rack::ENV_KEY_PARAMS] response = ::Rack::Response.new response.redirect(eval(%|"#{path}"|), status) response.finish } self end # Serves either files from a directory, or a single static file. def serves_static_from(root) if File.directory?(root) match_partially! @destination = ::Rack::File.new(root) else @destination = proc{|env| env['PATH_INFO'] = File.basename(root); ::Rack::File.new(File.dirname(root)).call(env)} end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
usher-0.8.3 | lib/usher/interface/rack/route.rb |
usher-0.8.2 | lib/usher/interface/rack/route.rb |
usher-0.8.1 | lib/usher/interface/rack/route.rb |