Open BryanJBryce opened 5 years ago
I don't really understand this request :)
Could you give me a bit more information about what you are suggesting?
Based on my own experience with the installer when I pass --api
it removes the browser pipeline from the router and doesn't generate views (for obvious reasons).
So if I want to have both a web app and an json api then I need to run the installer twice (once with the --api
flag and once with out it) and kind of merge the differences. Does that make any more sense?
@JohnKacz could you show me what that setup looks like? Do you have an example app on github that I could look at?
@JohnKacz I didn't think about running the installer twice.
Are there any guidelines around what controllers should look like in a scenario where your Phoenix app has a web + api pieces?
@riverrun When you currently run the installer you get the choice between api or web. The templates are set up this way too, as an either or, but not both. I'm thinking a good approach to be able to generate both would be to have separate templates for api and for web.
I'm not sure, however, what the best practice is for controllers when you have both web and api parts. Does everything go into the same controller or do you separate web and api pieces into separate controllers? I think both pieces would use leverage the same contexts though.
I'll do some asking on the Elixir Slack and maybe in search the forum.
@BryanJBryce that's the question I have - how best to set up the router and controllers. Once we have a better idea of what the recommended / best practices for that are, then we can work on implementing it.
@riverrun No I don't have anything right now but I'll try to get something up sooner or later.
@BryanJBryce I don't have any off the top of my head but it shouldn't be too hard to figure out. Just a different pipeline which pipes through different controllers/views.
If we create separate templates for API and Web we could offer to generate both API and Web files.