Class: Shorty::RootRedirect
- Inherits:
-
Object
- Object
- Shorty::RootRedirect
- Defined in:
- lib/shorty/root_redirect.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(url = '/new', status = 302) ⇒ RootRedirect
constructor
A new instance of RootRedirect.
Constructor Details
#initialize(url = '/new', status = 302) ⇒ RootRedirect
Returns a new instance of RootRedirect.
3 4 5 |
# File 'lib/shorty/root_redirect.rb', line 3 def initialize(url='/new', status=302) @url, @status = url, status end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/shorty/root_redirect.rb', line 7 def call(env) if env['REQUEST_PATH'] == '/' and env['REQUEST_METHOD'] == 'GET' [ @status, { 'Content-Type' => 'text/html', 'Location' => @url }, @url ] else [ 404, { 'Content-Type' => 'text/html' }, ''] end end |