carstengehling/route_downcaser — pull request #4 by amiel (2013-08-28 00:14:40+00:00)
Title: Option to ignore requests that match a regex

RouteDowncaser smartly does not alter query params. However, sometimes there are case-sensitive params in the url proper. In my case, I am using [Devise](https://github.com/plataformatec/devise), and the password reset token is provided as the path part `:id` which is case-sensitive.

This patch fixes the issue by providing an `:ignore` option. To use this option, you must add `DowncaseRouteMiddleware` to the middleware stack yourself.

**Example:**

```ruby
# Ignore Devise password reset urls
config.middleware.use "RouteDowncaser::DowncaseRouteMiddleware", ignore: /password_resets/
```

My original goal was to alter the railtie to load the middleware only if it was not already loaded. However, I could not get this to work. I can go into detail on why I couldn't get this to work if you like, but it's fairly involved so I'm not gonna go into it here yet.

The simplest alternative is to simply not add the middleware to the stack by default. This is what I've done here because that works for me, but it would be a breaking change (maybe that's ok, as the gem is pre 1.0).

Another possibility would be to allow the middleware to be in the stack twice, but use an env var (like `env['route_downcaser.downcased'] = true` to guard multiple runs. However, this seems a little messy to me.

Anyway, here's a pull request in case you like the feature. I'm happy to discuss how to handle the initialization issue, but if you simply don't like this feature then I'll just continue using my branch.

Thanks,

-Amiel