In the case of catchAll config, I suggest making the ability to add the statusCode for the response object:
So, instead of:
'catchAll' => ['site/maintenance']
Is to add the statusCode like:
'catchAll' => ['site/maintenance', 503]
Or:
'catchAll' => [
'route' => 'site/maintenance',
'statusCode' => 503
]
Because it always returns 200 which doesn't make sense in most of the cases.
I think this should be encapsulated inside a controller action. If I have multiple catchAll stubs I don't want to edit status codes in addition to action path and parameters.
Later on you'd think of setting the Retry-After header. Should it also go to the catchAll parameter?
I agree with @Kolyunya. That is easily doable in the action itself.
Thanks, I was able to add this line of code to the action and it solves the issue:
Yii::$app->response->statusCode = 503;
@Kolyunya, it can also handled this way:
$headers = Yii::$app->response->headers;
$headers->add('Retry-After', '30');
@devmustafa glad you were able to solve the issue! And thanks for the tip! :+1:
Most helpful comment
@Kolyunya, it can also handled this way:
$headers = Yii::$app->response->headers; $headers->add('Retry-After', '30');