You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes we make applications that needs API and web routes at the same time, so what we do is write two separate logic with the same code, but it has just one difference that is in the return type.
for example:
when you need to show users on the browser, you just return the view with users. and when you need to show users in the JSON structure, you just use resource collection or return a normal JSON response.
So I think it is a real problem when you are stuck in this situation! I mean we must make one controller and return one response for one operation, that should be self-management to return an appropriate response for API and web.
of course, it can manage by the developers but if the framework takes action to solve this problem, programming it will be easier and the programmer will be happier ;D
In my opinion, we should have the structure like this:
-- Http
---- Controllers
---- Requests
---- Responses
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Sometimes we make applications that needs API and web routes at the same time, so what we do is write two separate logic with the same code, but it has just one difference that is in the return type.
for example:
when you need to show users on the browser, you just return the view with users. and when you need to show users in the JSON structure, you just use resource collection or return a normal JSON response.
So I think it is a real problem when you are stuck in this situation! I mean we must make one controller and return one response for one operation, that should be self-management to return an appropriate response for API and web.
of course, it can manage by the developers but if the framework takes action to solve this problem, programming it will be easier and the programmer will be happier ;D
In my opinion, we should have the structure like this:
-- Http
---- Controllers
---- Requests
---- Responses
Beta Was this translation helpful? Give feedback.
All reactions