Closed PerryRylance closed 4 months ago
I'm afraid that is expected. The parameters of the handle
method of the middleware are not resolved out of the Service Container, therefore the package doesn't have any control there.
What you can do is manually wrap the $request
like this
public function handle(Request $request, Closure $next)
{
$htmxRequest = HtmxRequest::createFrom($request);
return $next($htmxRequest);
}
Thank you!
I'm trying to establish if a request was made by HTMX in some middleware.
I have installed the package and published the config.
My middleware is receiving a regular
Request
and not aHtmxRequest
so trying to call the helper methods causes an exception to be thrown.Have I done something wrong here or is this expected?