Skip to content

Commit

Permalink
Allow response to replace headers via config
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Mar 1, 2025
1 parent 43aee7a commit ed98bb8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ Response Config Options
'csp' => [],
'csp_report_only' => [],
'json_flags' => null,
'replace_headers' => false,
'request_instance' => 'default',
],
],
Expand Down Expand Up @@ -1065,6 +1066,11 @@ json_flags

Flags for ``json_encode``. The default is set to none.

replace_headers
"""""""""""""""

Set ``true`` to force header replacement. Default is ``false`` to not replace.

request_instance
""""""""""""""""

Expand Down
3 changes: 3 additions & 0 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,9 @@ protected static function setResponse(string $instance) : Response
if (isset($config['json_flags'])) {
$service->setJsonFlags($config['json_flags']);
}
if (isset($config['replace_headers'])) {
$service->setReplaceHeaders($config['replace_headers']);
}
return static::setService('response', $service, $instance);
}

Expand Down
1 change: 1 addition & 0 deletions tests/configs/response.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
],
],
'json_flags' => \JSON_THROW_ON_ERROR,
'replace_headers' => false,
'request_instance' => 'default',
],
];

0 comments on commit ed98bb8

Please sign in to comment.