Skip to content

Commit 4680289

Browse files
authored
refactor(http): resolve HttpApplication via the container (#606)
1 parent 9289ffb commit 4680289

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Tempest/Http/src/HttpApplication.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Tempest\Http;
66

77
use Tempest\Container\Container;
8+
use Tempest\Container\Singleton;
89
use Tempest\Core\AppConfig;
910
use Tempest\Core\Application;
1011
use Tempest\Core\Kernel;
@@ -16,6 +17,7 @@
1617
use Tempest\Support\PathHelper;
1718
use Throwable;
1819

20+
#[Singleton]
1921
final readonly class HttpApplication implements Application
2022
{
2123
public function __construct(private Container $container)
@@ -29,17 +31,11 @@ public static function boot(
2931
): self {
3032
$container = Tempest::boot($root, $discoveryLocations);
3133

32-
// Application,
33-
// TODO: can be refactored to resolve via the container
34-
$application = new HttpApplication($container);
35-
36-
$container->singleton(Application::class, fn () => $application);
37-
38-
$root = $container->get(Kernel::class)->root;
34+
$application = $container->get(HttpApplication::class);
3935

4036
// Application-specific setup
4137
$logConfig = $container->get(LogConfig::class);
42-
$logConfig->debugLogPath = PathHelper::make($root, '/log/debug.log');
38+
$logConfig->debugLogPath = PathHelper::make($container->get(Kernel::class)->root, '/log/debug.log');
4339
$logConfig->serverLogPath = env('SERVER_LOG');
4440
$logConfig->channels[] = new AppendLogChannel(PathHelper::make($root, '/log/tempest.log'));
4541

0 commit comments

Comments
 (0)