Class: Goliath::Rack::Params

Inherits:
Object
  • Object
show all
Includes:
Parser, Validator
Defined in:
lib/goliath/rack/params.rb

Overview

A middle ware to parse params. This will parse both the query string parameters and the body and place them into the params hash of the Goliath::Env for the request.

Examples:

use Goliath::Rack::Params

Defined Under Namespace

Modules: Parser

Instance Method Summary collapse

Methods included from Parser

#retrieve_params

Methods included from Validator

safely, validation_error

Constructor Details

#initialize(app) ⇒ Params

Returns a new instance of Params.



58
59
60
# File 'lib/goliath/rack/params.rb', line 58

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/goliath/rack/params.rb', line 62

def call(env)
  error_response = Goliath::Rack::Validator.safely(env) do
    env['params'] = retrieve_params(env)
    nil
  end
  error_response || @app.call(env)
end