steveklabnik / request_store

Per-request global storage for Rack.
https://github.com/steveklabnik/request_store
MIT License
1.48k stars 87 forks source link

No such middleware to insert after: Rack::MethodOverride (RuntimeError) #27

Closed biinari closed 10 years ago

biinari commented 10 years ago

When using rails-api, or any setup where the middleware Rack::MethodOverride is not present, it fails to add the request store middleware.

No such middleware to insert after: Rack::MethodOverride (RuntimeError)

Would it be reasonable to check whether Rack::MethodOverride is in the middleware list to decide whether to insert after it?

steveklabnik commented 10 years ago

Ah yes, this should be addressed. That's the right way to do it, yes. If it's not there we can fall back to the old behavior.

Would you like to work up a patch, or should I?

biinari commented 10 years ago

I'll make a pull request

will-r commented 10 years ago

I guess the original intention was to load after rack but before rails? Works for me if I just replace Rack::MethodOverride with Rack::Runtime:

    initializer "request_store.insert_middleware" do |app|
      app.config.middleware.insert_after Rack::Runtime, RequestStore::Middleware
    end