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.