private function loadMiddlewares($app, $container)
    {
        # Tracy debugbar
        $debugbar_enabled = filter_var(app_env('DEBUG_BAR_ON', false), FILTER_VALIDATE_BOOLEAN);
        if (is_dev() && $debugbar_enabled && PHP_SAPI !== "cli")
        {
            $app->add(new TracyMiddleware($app));
        }

        # Determine Route Before Application middleware
        $app->add(new AppMiddleware($container));

        # Global Error middleware
        $app->add(new GlobalErrorsMiddleware($container));

        # Old Input middleware
        $app->add(new OldInputMiddleware($container));

        # Global Csrf middleware
        $app->add(new GlobalCsrfMiddleware($container));
        $app->add($container->get('csrf'));

        # Shared Server middleware
        $app->add(new SharedServerMiddleware($container));

        # Application Mode middleware
        $app->add(new AppModeMiddleware($container));

        # Remove Trailing Slash middleware
        $app->add(new RemoveTrailingSlashMiddleware($container));
    }