dimanche 9 septembre 2018

Middleware not working on route when registered via Service Provider

I'm using https://github.com/nWidart/laravel-modules to create a module based application in laravel. One module Gateway is planned to use as API Gateway between other REST API. This module is highly inspired by https://github.com/PoweredLocal/vrata.

A middleware HelperMiddleware is created:

public function handle(Request $request /* custom request */, Closure $next, $id)
{
    $request->attachRoute(
        app()->make(RouteRegistry::class)->getRoute($id)
    );

    return $next($request);
}

Registered this middleware via ServiceProvider in the module:

$router = $this->app['router'];
$router->aliasMiddleware('gateway', HelperMiddleware::class);

And I tried to add this middleware in route but the middleware is not working.

Please help me resolving this issue. Code: https://github.com/itsursujit/blog



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2wVo9Pp
via IFTTT

Aucun commentaire:

Enregistrer un commentaire