Class: Rack::Robots

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/robots.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Robots

Returns a new instance of Robots.



3
4
5
# File 'lib/rack/robots.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rack/robots.rb', line 7

def call(env)
  if env["REQUEST_PATH"] == "/robots.txt" &&
    %w{1 true yes}.include?(ENV["DISABLE_ROBOTS"])
      [200, { 'Content-Type' => 'text/plain' }, <<-eos]
# this is a staging environment. please index the main site instead.
User-agent: *
Disallow: /
      eos
  else
    @app.call(env)
  end
end