-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add an Api Resource Controller #319
Conversation
One thing I'd love to start work on with Solidus is a second version of the API. I think we should move all API requests to a v1 namespace and maybe start building out a second API and deprecate this existing one and move it to its own gem. I have experimented with a I would personally try and put effort into building a V2, rather than refactoring the V1, but I'm 👍 for this PR. |
@athal7 I totally agree with you on the |
@BenMorganIO I'm all for a V2 if we have/desire breaking API changes. As long as the API contract is consistent here, I think we can do this refactoring in V1. And hopefully it will make the V2 build easier as well. I'm curious to chat through (on a separate thread maybe here) what you are looking to see from a V2, since I think a lot of people have opinions. |
@jhawthorn updated to authorize on new. I still think it makes sense to return an empty set and 404 respectively for index / show as opposed to 401ing, but happy to chat it through more. |
👍 |
ping @solidusio/owners curious to get some more eyes on this |
I would recommend using |
To abstract away a lot of the similarities among the api controllers. This should make it easier to make changes to how we do templating, authorization, or param whitelisting in the future.
@hhff updated |
👍 |
I think this looks good. 👍 from me; @jhawthorn should we merge this? Or loop another entity controller into it first? |
Yeah, I really like this 👍 |
Great; hitting merge here as Andrew is out. |
Add an Api Resource Controller
These were removed in solidusio#319 and replaced by generically-named equivalents, but controllers in apps like ours can be reasonably expecting these to be there.
To abstract away a lot of the similarities among the api controllers.
This should make it easier to make changes to how we do templating,
authorization, or param whitelisting in the future.
Even though the api/users_controller no longer has logic, I left the specs
in place for this PR to demonstrate API compatibility. Happy to remove them if we
see them as being superfluous.
I also chose to not reuse too many pieces of the admin/resource_controller because
there is a lot of hard-to-follow code in there, so hopefully this new one can be a
good clean space to refactor and then share code back to the admin/resource_controller.
More controllers to inherit from this later barring successful acceptance into the codebase.