Sha256: dd6cc8fed2a75cec66ad1cbbd9cdf991a1a1c538e6b9a318919246655ec8d7c9

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

# rack-filter-param

Refactoring something behind an API? Plagued by extraneous HTTP params? `rack-filter-param` might be for you.

## What is it?

[Rack](https://github.com/rack/rack) middleware to remove specific params from HTTP requests.

## What does it do?

Given a set of params and optional constraints, `rack-filter-param` will remove those params, then pass the request downstream.

Removes params from:

* GET querystring
* POST params (x-www-form-urlencoded)
* JSON or other params hitherto processed by [`ActionDispatch::ParamsParser`](http://api.rubyonrails.org/classes/ActionDispatch/ParamsParser.html)

## Installation

```ruby

gem 'rack-filter-param', require: 'rack/filter_param'
```

## Usage

In rackup file or `application.rb`, initialize `rack-filter-param` with a list of HTTP params you want filtered from requests.

Strip a parameter named `client_id`:

```ruby
use Rack::FilterParam, :client_id
```

Strip a parameter named `client_id` from a specific path only:

```ruby
use Rack::FilterParam, { param: :client_id, path: '/oauth/tokens' }
```

Strip a parameter named `client_id` from a fuzzy path:

```ruby
use Rack::FilterParam, { param: :client_id, path: /\A\/oauth/ }
```

To filter multiple parameters, an array of parameters or options hashes can also be passed.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rfwatson/rack-filter-param


## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-filter-param-0.1.0 README.md