class Rack::Ok

Constants

DEFAULT_REQUEST_PATH
DEFAULT_RESPONSE_BODY
VERSION

Public Class Methods

new( app, body: DEFAULT_RESPONSE_BODY, path: DEFAULT_REQUEST_PATH ) click to toggle source

@param [#call] app @param [String] body @param [String] path

# 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

Public Instance Methods

call(env) click to toggle source

@param [Hash] env Rack env. @return [Array] Rack response.

# 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