Class: Rack::Ok
- Inherits:
-
Object
- Object
- Rack::Ok
- Defined in:
- lib/rack/ok.rb,
lib/rack/ok/version.rb
Constant Summary collapse
- DEFAULT_REQUEST_PATH =
'/health'- DEFAULT_RESPONSE_BODY =
'OK'- VERSION =
'0.1.1'
Instance Method Summary collapse
-
#call(env) ⇒ Array
Rack response.
-
#initialize(app, body: DEFAULT_RESPONSE_BODY, path: DEFAULT_REQUEST_PATH) ⇒ Ok
constructor
A new instance of Ok.
Constructor Details
#initialize(app, body: DEFAULT_RESPONSE_BODY, path: DEFAULT_REQUEST_PATH) ⇒ Ok
Returns a new instance of Ok.
14 15 16 17 18 19 20 21 22 |
# File 'lib/rack/ok.rb', line 14 def initialize( app, body: DEFAULT_RESPONSE_BODY, path: DEFAULT_REQUEST_PATH ) @app = app @body = body @path = path end |
Instance Method Details
#call(env) ⇒ Array
Returns Rack response.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rack/ok.rb', line 26 def call(env) if env['PATH_INFO'] == @path [ 200, { 'content-length' => @body.bytesize.to_s, 'content-type' => 'text/plain' }, [@body] ] else @app.call(env) end end |