Bramus\Router\Router::before PHP Method

before() public method

Store a before middleware route and a handling function to be executed when accessed using one of the specified methods
public before ( string $methods, string $pattern, object | callable $fn )
$methods string Allowed methods, | delimited
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed
    public function before($methods, $pattern, $fn)
    {
        $pattern = $this->baseRoute . '/' . trim($pattern, '/');
        $pattern = $this->baseRoute ? rtrim($pattern, '/') : $pattern;
        foreach (explode('|', $methods) as $method) {
            $this->beforeRoutes[$method][] = array('pattern' => $pattern, 'fn' => $fn);
        }
    }