public BackendSplicerMiddleware(
     RequestDelegate next,
     BackendRegistry backendRegistry,
     LayoutRegistry layoutRegistry,
     ProxyHttpClient proxyHttpClient = null)
 {
     _next            = next;
     _backendRegistry = backendRegistry;
     _layoutRegistry  = layoutRegistry;
     _proxyHttpClient = proxyHttpClient ?? new ProxyHttpClient();
 }
        private static LayoutRegistry BuildLayoutRegistry(IConfigurationSection config)
        {
            var layoutsConfig = config.GetSection("Layouts");

            if (layoutsConfig == null)
            {
                throw new Exception("BackendSplicer.Layouts configuration section not found");
            }

            var layouts = new List <LayoutConfig>();

            layoutsConfig.Bind(layouts);

            var layoutRegistry = new LayoutRegistry();

            foreach (LayoutConfig layoutConfig in layouts)
            {
                layoutRegistry.Register(layoutConfig.Name, layoutConfig.Url, layoutConfig.Default);
            }
            return(layoutRegistry);
        }