Sha256: e044cb5bc8cfa7a078361456c455569b5863914f518ae044aa698625eb428410

Contents?: true

Size: 385 Bytes

Versions: 1

Compression:

Stored size: 385 Bytes

Contents

module Shorty
  class RootRedirect
    def initialize(url='/new', status=302)
      @url, @status = url, status
    end
  
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shorty_server-0.5.0 lib/shorty/root_redirect.rb