Skip to content

Commit

Permalink
Add support for HTTP/3 Early Hints
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning committed Nov 14, 2024
1 parent ac44a09 commit 7cedb0f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
"require": {
"php": "^8.1|^8.2|^8.3",
"blade-ui-kit/blade-heroicons": "^2.4",
"mailerlite/laravel-elasticsearch": "^11.1",
"illuminate/database": "^11.0",
"illuminate/events": "^11.0",
"illuminate/queue": "^11.0",
"illuminate/support": "^11.0",
"justbetter/laravel-http3earlyhints": "*",
"lcobucci/clock": "^2.0|^3.2",
"lcobucci/jwt": "^4.0|^5.3",
"mailerlite/laravel-elasticsearch": "^11.1",
"rapidez/blade-directives": "^0.6",
"tormjens/eventy": "^0.8"
},
Expand Down
4 changes: 4 additions & 0 deletions config/rapidez/routing.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@
// This does not cache the response, it caches the controller used for that page.
'cache_duration' => 3600,
],

'earlyhints' => [
'enabled' => env('EARLY_HINTS_ENABLED', true),
]
];
10 changes: 10 additions & 0 deletions src/RapidezServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ protected function bootRoutes(): self
RapidezFacade::addFallbackRoute(CmsPageController::class, 10);
RapidezFacade::addFallbackRoute(LegacyFallbackController::class, 99999);

if (!app()->runningInConsole() && config('rapidez.routing.earlyhints.enabled', true)) {
$this->app->call(function (\Illuminate\Contracts\Http\Kernel $kernel) {
/** @var \Illuminate\Foundation\Http\Kernel $kernel */
$middlewares = $kernel->getGlobalMiddleware();
$middlewares[] = \JustBetter\Http3EarlyHints\Middleware\AddHttp3EarlyHints::class;

$kernel->setGlobalMiddleware($middlewares);
});
}

return $this;
}

Expand Down

0 comments on commit 7cedb0f

Please sign in to comment.