Class: Mistiq::Middleware
- Inherits:
-
Object
- Object
- Mistiq::Middleware
- Defined in:
- lib/mistiq/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
9 10 11 |
# File 'lib/mistiq/middleware.rb', line 9 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mistiq/middleware.rb', line 13 def call(env) status, headers, response = @app.call(env) #if the current file is an HTML document if headers != nil && headers["Content-Type"] != nil && (headers["Content-Type"].include? "text/html") if ENV['REGEX'] != nil regex = ENV['REGEX'].split("@@@") body = response.body regex.each { |r| if r != 'POST' temp = body.gsub(/#{r}/,"") if temp != nil body = temp end end } #rebuild response response = Rack::Response.new(body,status,headers) response.finish else [status, headers, response] end else [status, headers, response] end end |