Right now `--api` is all or nothing. Most applications that have an API also 
have a companion web site. If you plan to keep separated applications, that's 
fine. The problem lies on using the same app for both your web site and API. 

My proposal is using whatever is defined as the `middleware_stack` on the 
controller, without injecting/merging any default behavior. In practice, we 
would set `ActionController::Base.middleware_stack` to 
`Rails::Application::DefaultMiddlewareStack.new` on railties, allowing 
replacement per controller basis, like the following:

```ruby
class ActionController::Base
  self.middleware_stack = Rails::Application::DefaultMiddlewareStack.new
end

class ApplicationController < ActionController::Base
end

class ApiController < ActionController::Base
  # This would override the super class (ActionController::Base) middleware 
stack.
  self.middleware_stack = ActionController::MiddlewareStack.new

  # This controller would have just the following middleware.
  use ::Rack::Runtime
end
```

I'm glad to hear your suggestions. I can happily jump on this.


Cheers,

--

Nando Vieira

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to