private function swishBefore()
  {
    $self = $this;
    return function($route, $callback) use ($self) {
      $route->variables = (new Reflect)->handle($callback, $route->variables, $route);

      // get controller middleware
      if (is_array($callback) && isset($callback[0]->middleware)) {
        $method = $callback[1];

        if ($callback[0]->middleware instanceof \Modulus\Http\Middleware) {
          $middleware = $callback[0]->middleware;

          if (count($middleware->only) > 0 && in_array($method, $middleware->only)) {
            $all = $middleware->all;
          } else if (count($middleware->except) > 0 && !in_array($method, $middleware->except)) {
            $all = $middleware->all;
          } else if (count($middleware->only) == 0 && count($middleware->except) == 0) {
            $all = $middleware->all;
          }
        }
      }

      // get all middleware's
      foreach (Route::$routes as $key => $value) {
        if ($value['id'] == $route->id) {
          $route->middleware = array_merge($value['middleware'], $all ?? []);
        }
      }

      // create a new request object
      $request = Reflect::$request ?? new Request(array_merge($_POST, $_FILES));
      $request->route = $route;
      $this->setRequest($request);

      // remove cors to allow the middleware to handle it
      $self->removeCors();
      Middleware::run($request, $route, substr($route->file, 0, strlen($route->file) - 4));

      // return matched variables
      return $route->variables;
    };
  }