Sinatra::Params

Installation

Add this line to your application's Gemfile:

gem 'sinatra-params'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sinatra-params

Usage

require 'sinatra'
require 'sinatra/params'

helpers Sinatra::Params

get '/' do
  param :id, Integer
  param :msg, String

  "#{params.id}: #{params.msg}"
end

Or if you are using Sinatra::Base

require 'sinatra/base'
require 'sinatra/params'

class Application < Sinatra::Base
  helpers Sinatra::Params

  get '/' do
    param :id, Integer
    param :msg, String

    "#{params.id}: #{params.msg}"
  end
end

License

The gem is available as open source under the terms of the MIT License.