public function map($method, string $route, string $action, string $controller)
    {
        // alias
        $proxy = $this->proxy_factory;

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

        // whitelist http methods
        \array_walk($method, function ($v) {
            if (!\in_array($v, ['GET', 'POST', 'PUT', 'DELETE'])) {
                throw new \InvalidArgumentException(\sprintf('Unknown http method: "%s"', $v));
            }
        });

        foreach ($method as $m) {
            $this->klein->respond($m, $route, function ($request, $response) use (&$proxy, $action, $controller) {

                return $proxy($controller)
                        ->setRequest($request)
                        ->setResponse($response)
                        ->$action();

            });
        }

        return $this;
    }
public function map($method, string $route, string $action, string $controller)
    {
        // alias
        $proxy = $this->proxy_factory;

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

        // whitelist http methods
        \array_walk($method, function ($v) {
            if (!\in_array($v, ['GET', 'POST', 'PUT', 'DELETE'])) {
                throw new \InvalidArgumentException(\sprintf('Unknown http method: "%s"', $v));
            }
        });

        foreach ($method as $m) {
            $this->klein->respond($m, $route, function ($request, $response) use (&$proxy, $action, $controller) {

                return $proxy($controller)
                        ->setRequest($request)
                        ->setResponse($response)
                        ->$action();

            });
        }

        return $this;
    }
public function map ( $ method , string $ route , string $ action , string $ controller ) { // alias $ proxy = $ this -> proxy_factory ; if ( ! \ is_array ( $ method ) ) { $ method = [ ( string ) $ method ] ; } // whitelist http methods \ array_walk ( $ method , function ( $ v ) { if ( ! \ in_array ( $ v , [ 'GET' , 'POST' , 'PUT' , 'DELETE' ] ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Unknown http method: "%s"' , $ v ) ) ; } } ) ; foreach ( $ method as $ m ) { $ this -> klein -> respond ( $ m , $ route , function ( $ request , $ response ) use ( & $ proxy , $ action , $ controller ) { return $ proxy ( $ controller ) -> setRequest ( $ request ) -> setResponse ( $ response ) -> $ action ( ) ; } ) ; } return $ this ; }
Map HTTP method and route to some action and controller.

@param mixed $method Uppercase HTTP method string or array of multiple methods.
@param string $route Concrete route or route pattern.
@param string $action Name of the action method that shall be called if route gets matched.
@param string $controller Fully qualified class name of the {@link Controller} that shall be invoked.
Map HTTP method and route to some action and controller .