This repository has been archived by the owner on Jan 17, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(swoole): Simplify booting services at runtime
Swoole server can affect configuration, and it has to be created at runtime due to host/port binding, after successful server boot, some services also can be reconfigured to allow simple configuration substitution via cli
- Loading branch information
Showing
24 changed files
with
741 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Bridge/Symfony/HttpFoundation/SetRequestRuntimeConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Bundle\SwooleBundle\Bridge\Symfony\HttpFoundation; | ||
|
||
use App\Bundle\SwooleBundle\Server\Runtime\BootableInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Sets symfony's request runtime configuration. | ||
*/ | ||
final class SetRequestRuntimeConfiguration implements BootableInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function boot(array $runtimeConfiguration = []): void | ||
{ | ||
if (\array_key_exists('trustedHosts', $runtimeConfiguration)) { | ||
Request::setTrustedHosts($runtimeConfiguration['trustedHosts']); | ||
} | ||
if (\array_key_exists('trustedProxies', $runtimeConfiguration)) { | ||
Request::setTrustedProxies($runtimeConfiguration['trustedProxies'], $runtimeConfiguration['trustedHeaderSet'] ?? Request::HEADER_X_FORWARDED_ALL); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.