Class: AdminIt::Middleware
- Inherits:
-
Object
- Object
- AdminIt::Middleware
- Defined in:
- lib/admin_it/middleware.rb
Overview
AdminIt middleware
Constant Summary collapse
- SUBST_REGEXP =
/<!--\s*([a-zA-Z0-9_]+)\s*-->/
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.
38 39 40 |
# File 'lib/admin_it/middleware.rb', line 38 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/admin_it/middleware.rb', line 42 def call(env) request = env[Request::ENV_KEY] = Request.new(env) status, headers, body = @app.call(env) if request.process? body.each do |str| # $1 not working here ??? str.gsub!(SUBST_REGEXP) { |s| request[SUBST_REGEXP.match(s)[1]] } end end [status, headers, body] end |