dispatch to action

@param   string  $path
@param   string  $method
@return  Closure
553934
public function dispatch($path = '/', $method = 'GET')
    {
        foreach ($this->rules as $rule)
        {
            if ($rule->matching($path, $method))
                return $rule->toActionCaller($path, $method);
        }
        throw new NotFoundException($path);
    }
797965
protected function createRoute($method, $path, $abstract) {
        if ($this->getPrefix() !== null) {
            $path = url($this->getPrefix(), $path);
        }

        if ( ! is_array($method)) {
            $method = [$method];
        }

        $handler = $this->createHandler($abstract);
        $route = new Route($method, $path, $handler);
        $this->routes[] = $route;

        return $this;
    }
764524
public function findFromPath($path, $method = null)
    {
        foreach ($this->getRoutes() as $route) {
            if ($matchedRoute = $route->matches($path, $method)) {
                return $matchedRoute;
            }
        }
        return null;
    }
877175
public function method($method = null, $path = '/')
    {
        $parameters = array();

        $parameters['path'] = $path;

        if($method)
            $parameters['method'] = $method;

        $route = $this->factory->createRoute($this, null, $parameters);

        $this->addRoute($route);

        return $route;
    }
110464
public function dispatchUri(string $path = null, string $method = null)
    {
        $path = (string)($path ?: $_SERVER['REQUEST_URI']);

        if (\strpos($path, '?')) {
            $path = \parse_url($path, \PHP_URL_PATH);
        }

        // if 'filterFavicon' setting is TRUE
        if ($path === self::FAV_ICON && $this->options['filterFavicon']) {
            return null;
        }

        $method = (string)($method ?: $_SERVER['REQUEST_METHOD']);
        $method = \strtoupper($method);

        /** @var Route $route */
        [$status, $path, $route] = $this->router->match($path, $method);

        return $this->dispatch($status, $path, $method, $route);
    }
3730
private function _call($method, $path, $param, $header = false) {
    // Clear connection; Set timeout, and json header.
    $this->curl->resetConnection();

    // Set additional headers.
    if ($header) {
      foreach ($header as $name => $value) {
        $this->curl->setHeader($name, $value);
      }
    }

    // Make an API request to the GDAX server.
    if ($param) {
      // If the method is not GET, pass JSON in the request body.
      $payload = false;
      if ($method != 'GET') {
        $param = json_encode($param);
        $payload = true;
      }
      $this->curl->{strtolower($method)}("$this->api/$path", $param, $payload);
    } else {
      $this->curl->{strtolower($method)}("$this->api/$path");
    }

    // TODO: Move error logs out of class. ~: Monolog
    // Error Logging
    if ($this->curl->error) {
      $this->_error[] = "$path: {$this->curl->error_message}";
      if ($this->_debug) {
        $this->_error[] = $this->_dump($path, $param);
      }
    }

    if (is_null($ret = json_decode($this->curl->response))) {
      throw new \Exception(__METHOD__ ." - Invalid JSON or null returned."); 
    }

    // Throw an exception on any returned messages from GDAX.
    if ($ret && isset($ret->message)) {
      throw new \Exception("API: $path-> ". $ret->message);
    }

    return $ret;
  }
929683
def dispatch_action(request)
      method = request_method(request)
      path = request.path.sub(/\.\w+$/, '')
      route = @routing.detect { |r| r[0] == method && r[1] == path }
      route[2] if route
    end
1184164
public function dispatch(string $method, string $url): array
    {
        $route = $this->match($url);

        $result = [
            'method' => $method,
            'url' => $url,
        ];

        if (!$route) {
            $result['error'] = 404;
        } elseif (isset($route['methods'][$method])) {
            $params = $route['params'];
            $handler = $route['methods'][$method];

            if (!$handler instanceof \Closure) {
                if (isset($handler['params'])) {
                    $params += $handler['params'];
                }

                $handler = [
                    'app' => $handler['app'] ?? $params['app'] ?? null,
                    'controller' => $handler['controller'] ?? $params['controller'] ?? null,
                    'action' => $handler['action'] ?? $params['action'] ?? null,
                ];
            }

            $result += [
                'route' => $route['route'],
                'params' => $params,
                'handler' => $handler,
            ];
        } else {
            $result += [
                'error' => 405,
                'route' => $route['route'],
                'params' => $route['params'],
                'allowed' => \array_keys($route['methods']),
            ];
        }

        return $this->result = $result;
    }
35568
protected function registerRoute($method, $path, $callback, $middleware = null)
    {
        if ($this->debug) echo __METHOD__ . " : " . json_encode([$method, $path, $callback, $middleware]) . PHP_EOL;
        $path = preg_replace('/\//', '\/', $path);
        $matched = preg_match_all('/\{([^\/]+)\}/', $path, $matches);
        if ($this->debug) echo "Regex Route Variable Components Matched: " . json_encode($matches) . PHP_EOL;
        if ($matched) {
            $regex = preg_replace('/\{([^\/]+)\}/', '([^\/]+)', $path);
        } else {
            $regex = $path;
        }
        $regex = '/^\/' . $regex . '$/';
        $new_route = [
            self::ROUTE_PARAM_METHOD => $method,
            self::ROUTE_PARAM_PATH => $regex,
            self::ROUTE_PARAM_CALLBACK => $callback,
            self::ROUTE_PARAM_MIDDLEWARE => $middleware,
        ];
        if ($this->debug) echo "New Regex Route: " . json_encode($new_route) . PHP_EOL;
        array_unshift($this->routes, $new_route);
    }
166862
public function dispatch(Route $route, $controller, $method)
    {

        // This is not very nice but with the current structure we have to throw
        // the previously created controller away.
        // For further implementations more cleanup has to be done
        $instance = $this->makeController(is_object($controller) ? get_class($controller) : $controller);

        $parameters = $this->resolveClassMethodDependencies(
            $route->parametersWithoutNulls(), $instance, $method
        );

        if ($this->creator && method_exists($this->creator, 'modifyMethodParameters')) {
            $this->creator->modifyMethodParameters($instance, $method, $parameters);
        }

        if (method_exists($instance, 'callAction')) {
            return $instance->callAction($method, $parameters);
        }

        return $instance->{$method}(...array_values($parameters));

    }
386868
function route(
    $path = '/', $actions, $method = Router::ANY_METHOD, $name = null, array $filters = [], array $events = []
    )
    {
        if (is_array($path)) {
            foreach ($path as $p) {
                $this->collection[$name ?: count($this->collection)] = (new Route($this->Parser))
                        ->route($p, is_array($actions) ? $actions : [$actions], $method, $name, $filters, $events);
            }
        } else {
            $this->collection[$name ?: count($this->collection)] = (new Route($this->Parser))
                    ->route($path, is_array($actions) ? $actions : [$actions], $method, $name, $filters, $events);
        }

        return $this;
    }
730250
protected function dispatchRouter($method, $path)
    {
        $router = $this->container['router'];
        $logger = $this->container['logger'];

        $logger->debug('Router dispatch.', ['method' => $method, 'path' => $path]);

        $router->init();
        $route_info = $router->dispatch($method, $path);

        $handler = null;
        $vars = [];

        switch ($route_info[0]) {
        case RouteDispatcher::NOT_FOUND:
            $logger->debug('Routing failed. Not Found.');
            throw new HttpNotFoundException('404 Not Found');
            break;
        case RouteDispatcher::METHOD_NOT_ALLOWED:
            $logger->debug('Routing failed. Method Not Allowd.');
            throw new HttpMethodNotAllowedException('405 Method Not Allowed');
            break;
        case RouteDispatcher::FOUND:
            $handler = $route_info[1];
            $vars = $route_info[2];
            $logger->debug('Route found.', ['handler' => $handler]);
            break;
        }

        return [$handler, $vars];
    }
533881
public function route(string $method, string $path, callable $callback, int $priority = 0)
    {
        $this->getRouter()->route($method, $path, $callback, $priority);

        return $this;
    }
1128152
private function redirect($method) {

		$this -> setUrl();
		$this -> setDomain();
		$this -> setMethod($method);
		
		Router :: setRedirect(true);

		return Router :: execute();
	}
1365701
function bind(method, path, controller, action) {
    let handler = controllerRegistry[controller] && controllerRegistry[controller][action]
    if (!handler) {
      console.warn(`can't bind route ${ path } to unknown action ${ controller }.${ action }`)
      return
    }

    const policyName = LocalUtil.getPolicyName(policy, controller, action)
    let currentPolicy
    if (policyName) currentPolicy = policyRegistry[policyName]

    if (currentPolicy) {
      router[method](path, currentPolicy, handler)
    } else {
      router[method](path, handler)
    }
  }
1078196
protected function dispatchRouter($method, $path)
    {
        $resolver   = $this->make('Glue\Router\RouterResolver');
        $dispatcher = new Dispatcher($this->router->getData(), $resolver);

        $httpCode = Response::HTTP_OK;
        $allow    = null;

        try {

            $response = $dispatcher->dispatch($method, $path);
            if ($response instanceof Response) {
                $httpCode = $response->getStatusCode();
            }

        } catch(HttpRouteNotFoundException $e) {

            $response = $this->router->resolveErrorHandler(Response::HTTP_NOT_FOUND);
            $httpCode = Response::HTTP_NOT_FOUND;

        } catch(HttpMethodNotAllowedException $e) {

            $response = $this->router->resolveErrorHandler(Response::HTTP_METHOD_NOT_ALLOWED);
            $httpCode = Response::HTTP_METHOD_NOT_ALLOWED;
            if (strpos($e->getMessage(), 'Allow:') === 0) {
                // We got an Allow-message as exception message.
                // Save it so we can add it to the response header
                $allow = trim(explode(':', $e->getMessage())[1]);
            }

        } catch(\Exception $e) {

            if ($this->bound('Psr\Log\LoggerInterface')) {
                $this->make('Psr\Log\LoggerInterface')
                    ->critical($e->getMessage(), [__METHOD__]);
            }

            throw $e;

        }

        if (!$response instanceof Response) {
            $response = new Response((string) $response);
            $response->setStatusCode($httpCode);
        }

        if ($allow) {
            $response->headers->set('Allow', $allow);
        }

        return $response;
    }
204203
public function requestPath($path, $method = null) {
        $this->setRequestPath($path);

        if (null === $method) {
            $this->setRequestMethod('GET', false);
        } else {
            $this->setRequestMethod($method);
        }

        return $this->sendRequest();
    }