simple-php-router icon indicating copy to clipboard operation
simple-php-router copied to clipboard

Inject something between route definition and final return? (Response-middleware)

Open esbenboye opened this issue 3 years ago • 0 comments

Brief elaboration on my use case(s):

When running my unit tests (environment = testing) it would be an advantage if I could return an entire response object from my controller, so I could analyse response headers (e.g. status code) and content.

When running in any other environment I would want my response to just return the rendered html without having to modify all my controller to have an if/else to check environment.

I also think it could be advantageous if I could just return a model from my controller and then have the "response middleware" check if the request accepted json or xml and then do the appropriate conversion, so I don't have to think about it in the controller.

Is this possible somehow?

esbenboye avatar Aug 29 '22 06:08 esbenboye