/**
  * Invoke middleware.
  *
  * @param Request        $request
  * @param RequestContext $context
  * @param Closure        $next
  * @param string|null    $action
  *
  * @return Response|null
  */
 public function __invoke(Request $request, RequestContext $context, Closure $next, $action = null)
 {
     if (null !== $action) {
         if ($this->isExcept($action)) {
             return $next();
         }
         if ($this->isNotOnly($action)) {
             return $next();
         }
     }
     return $this->middleware->handle($request, $context, $next);
 }
 /**
  * Register middleware.
  *
  * @param MiddlewareInterface $middleware
  */
 public function set(MiddlewareInterface $middleware)
 {
     $this->middlewares[$middleware->getName()] = $middleware;
 }