class Rack::RootApex

Constants

VERSION

Public Class Methods

new(app) click to toggle source
# File lib/rack/root-apex.rb, line 5
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/root-apex.rb, line 9
def call(env)
  request = Rack::Request.new(env)

  if request.host.start_with?('www.')
    [301, { 'Location' => request.url.sub('//www.', '//') }, ["Moved Permanently\n"]]
  else
    @app.call(env)
  end
end