Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with only a subset of controllers? #1

Closed
ileitch opened this issue Apr 20, 2012 · 5 comments
Closed

Use with only a subset of controllers? #1

ileitch opened this issue Apr 20, 2012 · 5 comments
Milestone

Comments

@ileitch
Copy link

ileitch commented Apr 20, 2012

My API is contained within a larger Rails app. They all inherit from a common parent class, so I can easily change them to use ActionController::API, however I'm unsure what to do about the Rails::ApiApplication setup step?

Cheers

@spastorino
Copy link
Contributor

We are going to add a config.api_only! option inside config/application.rb so if you add this config middleware stack will be reduced and if not you keep previous state. After that you will be able to just inherit from ActionController::API. Anyway I'm interested in seeing if that worth, I mean how much that improves. If you can measure it and share results :).
Thanks for helping.

Ahh another thing, there's no Rails::ApiApplication anymore, the README is fixed now.

@carlosantoniodasilva
Copy link
Member

The idea behing the config is that it will reduce your middleware stack and reconfigure some generators to not generate stuff like templates and assets - css/js. In case of shared apps, this option cannot be used because you'll lose features like session/cookies, which are required for the non-api part of your app. So the best usage in this case is inheriting from ActionController::API only, and ignore the config.

(of course this is not possible right now because everything is happening inside normal Rails::Application class, there's no config yet).

@ileitch
Copy link
Author

ileitch commented Apr 21, 2012

OK, so I got my API working by just using ActionController::API, but is this giving much benefit? Isn't the removal the main advantage of this plugin?

@carlosantoniodasilva
Copy link
Member

You're getting the benefit of having a smaller set of features in your controllers that handle the API part of your app, which should give you some improvement, but the middleware stack stays the same, so yeah no gain on that side.

We can't say for sure the real gain on this scenario, perhaps you can help us measuring this :). Thanks.

@spastorino
Copy link
Contributor

@ileitch can you check this out?, thanks!

steveklabnik pushed a commit that referenced this issue Oct 10, 2014
merge other junk into mine
j-wilkins pushed a commit to j-wilkins/rails-api that referenced this issue Oct 23, 2014
j-wilkins pushed a commit to j-wilkins/rails-api that referenced this issue Oct 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants