Class: Rack::Blank
- Inherits:
-
Object
- Object
- Rack::Blank
- Defined in:
- lib/rack/blank.rb,
lib/rack/blank/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Blank
constructor
A new instance of Blank.
Constructor Details
#initialize(app, options = {}) ⇒ Blank
Returns a new instance of Blank.
7 8 9 10 |
# File 'lib/rack/blank.rb', line 7 def initialize(app, = {}) @app = app @path = [:path] || '/blank' end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rack/blank.rb', line 12 def call(env) request_path = "#{::File.dirname(env['PATH_INFO'])}/#{::File.basename(env['PATH_INFO'], '.*')}" request_ext = ::File.extname(env['PATH_INFO']) if request_path == @path body = '' content_type = 'text/plain' if env['CONTENT_TYPE'] == 'application/json' || request_ext == '.json' body = JSON.generate({}) content_type = 'application/json' end headers = { "Content-Length" => body.bytesize.to_s, "Content-Type" => content_type } return [200, headers, [body]] end return @app.call(env) end |