DASPRiD / Dash

Flexible PSR-7 compliant HTTP router
BSD 2-Clause "Simplified" License
29 stars 9 forks source link

Add semi-automatic response-modfication #64

Closed DASPRiD closed 8 years ago

DASPRiD commented 8 years ago

This PR adds the possibility for match results to modify the response object. Specifically, this has the following use case:

When a response is not successful, it can take care of modifying the response object, instead of leaving the application to handle that job. Currently, the following cases are handled:

Example usage:

$matchResult = $router->match($request);

if (!$matchResult->isSuccess()) {
    $response = $matchResult->modifyResponse($response);
    // Bubble up the response
}
danizord commented 8 years ago

Dislike it - too much responsabilities for a router :(

DASPRiD commented 8 years ago

I kinda agree. This is definitely not the responsibility of the match results. It may still be part of the router, but for now I'll close this and maybe bring it up later again.