Class: Middleman::PhpMiddleware
- Inherits:
-
Object
- Object
- Middleman::PhpMiddleware
- Defined in:
- lib/middleman-php/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ PhpMiddleware
constructor
A new instance of PhpMiddleware.
Constructor Details
#initialize(app) ⇒ PhpMiddleware
Returns a new instance of PhpMiddleware.
4 5 6 |
# File 'lib/middleman-php/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 20 |
# File 'lib/middleman-php/middleware.rb', line 8 def call(env) status, headers, response = @app.call(env) if env['REQUEST_PATH'] =~ /\.php$/ response.body.map! do |item| `echo #{Shellwords.escape(item)} | php` end headers['Content-Length'] = response.body.join.length.to_s headers['Content-Type'] = 'text/html' end [status, headers, response] end |