Class: Bard::Static::NoRobotsMiddleware
- Inherits:
-
Object
- Object
- Bard::Static::NoRobotsMiddleware
- Defined in:
- lib/bard/static/no_robots_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ NoRobotsMiddleware
constructor
A new instance of NoRobotsMiddleware.
Constructor Details
#initialize(app) ⇒ NoRobotsMiddleware
Returns a new instance of NoRobotsMiddleware.
4 5 6 |
# File 'lib/bard/static/no_robots_middleware.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bard/static/no_robots_middleware.rb', line 8 def call(env) status, headers, response = @app.call(env) if env["bard_static.prototype"] && status == 200 no_robots_tag = %{<meta name="robots" content="noindex, nofollow"/>\n} response.each do |part| part.sub! "</head>", "#{no_robots_tag}</head>" end end [status, headers, response] end |