Class: Middleman::ProtectEmailsExtension::Middleware
- Inherits:
-
Object
- Object
- Middleman::ProtectEmailsExtension::Middleware
- Defined in:
- lib/middleman-protect-emails/extension.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
14 15 16 17 |
# File 'lib/middleman-protect-emails/extension.rb', line 14 def initialize(app, = {}) @rack_app = app @middleman_app = [:middleman_app] end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/middleman-protect-emails/extension.rb', line 19 def call(env) status, headers, response = @rack_app.call(env) # Get path path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app) # Match only HTML documents if path =~ /(^\/$)|(\.(htm|html)$)/ body = ::Middleman::Util.extract_response_text(response) if body status, headers, response = Rack::Response.new(rewrite_response(body), status, headers).finish end end [status, headers, response] end |