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
{{ message }}
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.
Hello,
Thank you for this well explained demo of Lucid.
I have a question regarding RespondWithJsonJob and RespondWithViewJob.
If my feature should serve both API and Web Controllers. They have exactly the same logic except for the last line which returns either JSON or a view.
What is your recommended solution here?
I am thinking about creating a Middleware where I inject into the Request object a value (e.g. source [WEB, API]) which determines whether the request is an API or Web.
And then inside the feature, I have two options:
Create an Operation e.g. RespondOperation, that takes the source variable, and based on that, it will run either RespondWithJsonJob or RespondWithViewJob.
Add if; else inside the feature to determine which response job based on the source.
The text was updated successfully, but these errors were encountered:
Ideally it should be a feature per service, one to serve the API and another to serve Web because if they currently do the same thing at some point you might start seeing differences in the way they're handled based on the request origin.
If you would still prefer to have the same feature, option n.1 is a good approach. And if you would like to take this further you can use the strategy pattern and have the response mutate itself.
Hello,
Thank you for this well explained demo of Lucid.
I have a question regarding RespondWithJsonJob and RespondWithViewJob.
If my feature should serve both API and Web Controllers. They have exactly the same logic except for the last line which returns either JSON or a view.
What is your recommended solution here?
I am thinking about creating a Middleware where I inject into the Request object a value (e.g. source [WEB, API]) which determines whether the request is an API or Web.
And then inside the feature, I have two options:
The text was updated successfully, but these errors were encountered: