Trying to create an app with Elixir + Phoenix, that would be able to handle both "browser" and "api" requests to handle its resources.
Is it possible to do it without having to do something like that :
scope "/", App do
pipe_through :browser
resources "/users", UserController
end
scope "/api", App.API as: :api do
pipe_through :api
resources "/users", UserController
end
which would mean having to create two controllers, which might have the same behavior, except that it will render HTML with the browser pipeline and, say JSON, for the api pipeline.
I was thinking maybe something like the Rails respond_to do |format| ...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…