private function setupScript($routeIdent, $scriptConfig)
    {
        $routePattern = isset($scriptConfig['route'])
            ? $scriptConfig['route']
            : '/'.ltrim($routeIdent, '/');

        $scriptConfig['route'] = $routePattern;

        $methods = isset($scriptConfig['methods'])
            ? $scriptConfig['methods']
            : [ 'GET' ];

        $routeHandler = $this->app->map(
            $methods,
            $routePattern,
            function (
                RequestInterface $request,
                ResponseInterface $response,
                array $args = []
            ) use (
                $routeIdent,
                $scriptConfig
            ) {
                if (!isset($scriptConfig['ident'])) {
                    $scriptConfig['ident'] = ltrim($routeIdent, '/');
                }

                $this['logger']->debug(
                    sprintf('Loaded script route: %s', $scriptConfig['ident']),
                    $scriptConfig
                );

                if (!isset($scriptConfig['script_data'])) {
                    $scriptConfig['script_data'] = [];
                }

                if (count($args)) {
                    $scriptConfig['script_data'] = array_merge(
                        $scriptConfig['script_data'],
                        $args
                    );
                }

                $defaultController = $this['route/controller/script/class'];
                $routeController   = isset($scriptConfig['route_controller'])
                    ? $scriptConfig['route_controller']
                    : $defaultController;

                $routeFactory = $this['route/factory'];
                $routeFactory->setDefaultClass($defaultController);

                $route = $routeFactory->create($routeController, [
                    'config' => $scriptConfig,
                    'logger' => $this['logger']
                ]);

                return $route($this, $request, $response);
            }
        );

        if (isset($scriptConfig['ident'])) {
            $routeHandler->setName($scriptConfig['ident']);
        }

        return $routeHandler;
    }