public function register($method, $path, $action, $filter = null)
    {
        // Add leading slash if not present
        if (strncmp($path, '/', 1) !== 0) {
            $path = '/' . $path;
        }

        // Add API base url to the path
        $path = $this->app->config('url.root') . $path;

        // Create arrays
        $params = [];
        $matches = [];
        $method = strtolower($method);

        // Replace placeholders
        if (preg_match_all('/\{([\w-\.]+)\}/i', $path, $matches)) {
            $params = end($matches);
        }
        $pattern = preg_replace(
            ['/(\{[\w-\.]+\})/i', '/\\//'],
            ['([\w-\.]+)', '\\/'],
            $path
        );

        // Store in the routes array
        return $this->routes[$method][$path] = [
            'path' => $path,
            'pattern' => '/^' . $pattern . '\\/?$/i',
            'class' => $action[0],
            'method' => $action[1],
            'params' => $params,
            'filter' => $filter
        ];
    }
public function register($method, $path, $action, $filter = null)
    {
        // Add leading slash if not present
        if (strncmp($path, '/', 1) !== 0) {
            $path = '/' . $path;
        }

        // Add API base url to the path
        $path = $this->app->config('url.root') . $path;

        // Create arrays
        $params = [];
        $matches = [];
        $method = strtolower($method);

        // Replace placeholders
        if (preg_match_all('/\{([\w-\.]+)\}/i', $path, $matches)) {
            $params = end($matches);
        }
        $pattern = preg_replace(
            ['/(\{[\w-\.]+\})/i', '/\\//'],
            ['([\w-\.]+)', '\\/'],
            $path
        );

        // Store in the routes array
        return $this->routes[$method][$path] = [
            'path' => $path,
            'pattern' => '/^' . $pattern . '\\/?$/i',
            'class' => $action[0],
            'method' => $action[1],
            'params' => $params,
            'filter' => $filter
        ];
    }
public function register ( $ method , $ path , $ action , $ filter = null ) { // Add leading slash if not present if ( strncmp ( $ path , '/' , 1 ) !== 0 ) { $ path = '/' . $ path ; } // Add API base url to the path $ path = $ this -> app -> config ( 'url.root' ) . $ path ; // Create arrays $ params = [ ] ; $ matches = [ ] ; $ method = strtolower ( $ method ) ; // Replace placeholders if ( preg_match_all ( '/\{([\w-\.]+)\}/i' , $ path , $ matches ) ) { $ params = end ( $ matches ) ; } $ pattern = preg_replace ( [ '/(\{[\w-\.]+\})/i' , '/\\//' ] , [ '([\w-\.]+)' , '\\/' ] , $ path ) ; // Store in the routes array return $ this -> routes [ $ method ] [ $ path ] = [ 'path' => $ path , 'pattern' => '/^' . $ pattern . '\\/?$/i' , 'class' => $ action [ 0 ] , 'method' => $ action [ 1 ] , 'params' => $ params , 'filter' => $ filter ] ; }
Register a url

@param string $method Method
@param string $path Route to match
@param array $action Controller and method to execute
@param array $filter Optional filter to execute
@return boolean Success or fail of registration
Register a url