-
-
Notifications
You must be signed in to change notification settings - Fork 962
Provide an easy way to override the status code dynamically #7903
Copy link
Copy link
Open
Description
Description
Maybe this already exists and I don't find it but I'd have a POST route I'd like to return a respond with either a 200 or a 202 status code.
Currently this does not seems to be supported since the Operation::getStatusCode is a single integer.
Does it exists @soyuka ? Are you ok with such feature ?
What do you recommend for this ?
I'm not sure but if the status is coming for here
| $status = $this->getStatus($request, $operation, $context); |
It could be easy to change here
| $status = $operation->getStatus(); |
into
$status = $request->attributes('_api_response_status', $operation->getStatus());
Example
class MyProcessor
{
public function process()
{
if ($count > 25) {
$request->attributes->set('_api_response_status', 202);
$dispatcher->publish(...);
} else {
// default status will be 200
$service->execute(...);
}
return $output;
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels