@param string $handler
@param array  $params

@return string
332683
public static function relative($handler, array $params = [])
    {
        return substr(app()->request->base_url, 0, -1).app()->router->generate($handler, $params);
    }
1166119
public function sendRequest($handlerName, $params = array(), $body = null, $headers = null, array $options = array())
    {
        $handler = $this->getRequestHandler($handlerName);
        $params = $this->normalizeParams($handler, $params);

        // For GETs and HEADs, the params are the query string. For POSTs
        // without a body, the params are post data. For POSTs with a body, the
        // params are the qstring.
        $method = $handler->getMethod();
        if ('GET' == $method || 'HEAD' == $method) {
            $options['query'] = $params;
        } elseif ('POST' == $method) {
            if (null === $body) {
                $body = $params;
            } else {
                $options['query'] = $params;
            }
        }

        $request = $this->createRequest($method, $handler->getPath(), $headers, $body, $options);
        $response = $request->send();
        return $this->parseResponse($response, $params);
    }
925973
protected function reflection($handler)
    {
        if (! is_array($handler))
        {
            $instance = new \ReflectionFunction($handler);

            return array($handler, $instance);
        }

        list($class, $method) = (array) $handler;

        $instance = new \ReflectionMethod($class, $method);

        $handler = array($this->instance($class), $method);

        return array((array) $handler, $instance);
    }
576951
public function validateArguments($methods, $handler): array
    {
        if (!$methods || !$handler) {
            throw new \InvalidArgumentException('The method and route handler is not allow empty.');
        }

        $allow = self::ALLOWED_METHODS_STR . ',';
        $hasAny = false;

        $methods = \array_map(function ($m) use ($allow, &$hasAny) {
            $m = \strtoupper(trim($m));

            if (!$m || false === \strpos($allow, $m . ',')) {
                throw new \InvalidArgumentException("The method [$m] is not supported, Allow: " . trim($allow, ','));
            }

            if (!$hasAny && $m === self::ANY) {
                $hasAny = true;
            }

            return $m;
        }, (array)$methods);

        return $hasAny ? self::ALLOWED_METHODS : $methods;
    }
1025785
public function setHandler($handler = null)
    {
        $this->handler = null !== $handler ? (string)$handler: $handler;

        return $this;
    }
12733
public function push($handler)
    {
        if (!$handler) {
            return $this;
        }
        if ($this->next) {
            return $this->next->push($handler);
        }
        if (!$handler instanceof MiddlewareInterface) {
            $handler = new Middleware($handler);
        }
        $this->next = $handler;
        return $this->next;
    }
478237
public function addEventHandler($name, $handler, array $params = []) {
        if (is_string($handler)) {
            $this->eventHandlers[$name] = [
                'handler' => $handler,
                'params' => $params,
            ];
        } else {
            $this->eventHandlers[$name] = $handler;
        }

        return $this;
    }
1359511
private function fromAtNotation($handler)
    {
        $parts = explode(self::CHAR_AT, $handler);
        if (count($parts) != 2) {
            throw new \InvalidArgumentException('Invalid Class Method format from "at" notation.');
        }
        $this->class = $parts[0];
        $this->method = $parts[1];
    }
1289514
public function executeHandler($handler, $params, $prevOutput = null)
    {
        // a function(-ish) thing which can be called
        if (is_callable($handler)) {
            return $handler($this, $params, $prevOutput);
        }

        // aliased handler
        if ($actualHandler = @$this->handlerAlias[$handler]) {
            return $this->executeHandler($actualHandler, $params, $prevOutput);
        }

        // only callable and controller/method pair (`:` seprated string) can be accepted
        if (!is_string($handler)) {
            $type = gettype($handler);
            throw new \Exception("'{$type}' can not be used as handler, should be a callable or controller/method pair!");
        }

        if (false === $pos = strpos($handler, ':')) {
            throw new \Exception("Can not parse '{$handler}' for corresponding controller/method!");
        }

        // controller/method pair
        list($class, $method) = explode(':', $handler, 2);
        $class = $this->handlerClassPrefix ? "{$this->handlerClassPrefix}{$class}" : $class;
        $controller = new $class;
        return $controller->$method($this, $params, $prevOutput);
    }
875313
protected function handle($handler, array $params = null)
    {
        ++$this->count;
        if ($this->count > $this->max) {
            throw HttpErrorException::create(500, [
                'code' => 500,
                'message' => 'Action forward is too much',
            ]);
        }

        try {
            return $this->app->handle($handler, $params);
        } catch (ActionForward $e) {
            return $this->handle($e->getHandler(), $e->getParams());
        } catch (BadRequestException $e) {
            throw HttpErrorException::create($e->getCode(), [
                'code' => $e->getCode(),
                'message' => $e->getMessage(),
            ], $e);
        }
    }
700
public function to($handler /*, $args… */)
    {
        $args = array_slice(func_get_args(), 1);

        return $this->then(
            function (Allocation $allocation) use ($handler, $args) {
                try {
                    $result = call_user_func_array($handler, $args);
                    $result = \React\Promise\resolve($result);
                    $result->then(array($allocation, 'releaseAll'), array($allocation, 'releaseAll'));
                } catch (\Exception $e) {
                    $result = new RejectedPromise($e);
                    $allocation->releaseAll();
                }

                return $result;
            }
        );
    }
731863
public static function init ($handler) {
		self::$handler = $handler;
		self::$destructor = new \Analog\Handler\Buffer\Destructor ();

		return function ($info) {
			Buffer::$buffer .= vsprintf (\Analog\Analog::$format, $info);
		};
	}
556641
protected function script($id, $params)
    {
        $handler       = $this->handler = 'handler' . str_random(4);
        $options       = array_replace_recursive($this->defaults()['pluginOptions'], $params['pluginOptions']);
        $decorated     = JavaScriptDecorator::decorate($options);
        return $this->init($id) . $handler . '.' . $this->pluginName . '(' . $decorated . ')';
    }
1015068
private function invokeCallback ( Request $request, $handler ) {
      try {
        return call_user_func_array( $handler, array( $this, $request ) );
      } catch ( \Exception $ex ) {
        $this->exception = $ex;
        return call_user_func_array( $this->onException, array( $this, $request ) );
      }
    }
739986
public function handle($handler = null, array $params = null): ResponseInterface
    {
        $handler = $this->handler($handler);
        $params = $this->params($params);

        $parameters = null;
        if (!$handler instanceof \Closure) {
            [$class, $method] = $this->convert($handler);

            if ($method === null) {
                $key = $handler = $class;
            } else {
                $controller = new $class;
                $handler = [$controller, $method];
                $key = "{$class}::{$method}";
            }

            $parameters = self::optimizeGet($key);
            if ($parameters === false) {
                $parameters = Builder::getCallableParameters($handler, true);
                self::optimizeSet($key, $parameters);
            }
        }

        $result = $this->container->call($handler, $params, $parameters);

        if ($result instanceof ResponseInterface) {
            return $result;
        }

        /** @var Response $response */
        $response = $this->get('response');

        return $response->default($result);
    }
1056391
static function trigger($event, $params = [], $all = true)
    {
        $result = [];
        if (isset(self::$handlers[$event])) {
            foreach (self::$handlers[$event] as $key => $handler) {
                if (isset($handler[0]) && (empty($handler[0]) || mb_strpos($handler[0], '/') !== false)) {
                    $out = call_user_func_array([\boolive\core\data\Data::read($handler[0]), $handler[1]], $params);
                } else {
                    $out = call_user_func_array($handler, $params);
                }
                if ($out === false){
                    if (!$all) return $out;
                }else{
                    $result[$key] = $out;
                }
            }
        }
        if (count($result) ==0 && !$all){
            return null;
        }
        return $result;
    }
1034802
private function vetHandler ( $handler ) {
      if ( is_callable( $handler ) )
        return $handler;
      else if ( is_string( $handler ) && preg_match( "/^.+\#.+$/", $handler ) == 1 )
        return function ( $service, $request ) use ( $handler ) {
          list($controller, $method) = explode( '#', $handler );
          $controller = new $controller( $service );
          return $controller->{$method}( $request );
        };
      return NULL;
    }