Integrated icon indicating copy to clipboard operation
Integrated copied to clipboard

Using TerminableMiddleware 'terminate' functions is not called

Open raultm opened this issue 10 years ago • 0 comments

Working with Laravel.

It's kind of weird but if I use the TerminableMiddleware Implementation the terminate function is not called. I thought I was doing something wrong and it could lead to wasted time trying to figure the problem in other context.

class CustomMiddleware implements TerminableMiddleware {

    public function handle($request, Closure $next)
    {
        $response = $next($request);

        return $response;
    }

    public function terminate($request, $response)
    {
        Query::createFromRequestResponse($request, $response);
    }

}

Of course, I can recreate the same behaviour using the handle function.

class CustomMiddleware {

    public function handle($request, Closure $next)
    {
        $response = $next($request);

        Query::createFromRequestResponse($request, $response);

        return $response;
    }

}

raultm avatar Apr 06 '15 13:04 raultm