private IHttpActionResult PerformBackendServerAction(HAProxyBackendServerRequest request, Func <HaProxyClient, BackendServer> action) { if (action == null) { throw new ArgumentNullException(nameof(action)); } if (!IsValid(request, out IHttpActionResult invalidResult)) { return(invalidResult); } if (request == null) { throw new InvalidOperationException(); } HaProxyClient client = request.CreateClient(); BackendServer backendServer = action(client); if (backendServer == null) { return(NotFound()); } return(Ok(backendServer)); }
public void Init() { if (server != null) { server.StopServer(); } server = new BackendServer() { Port = 4000 }; }
private static ApplicationGatewaySetConfiguration GenerateConfig() { ApplicationGatewaySetConfiguration config = new ApplicationGatewaySetConfiguration(); var frontEndIP1 = new FrontendIPConfiguration { Name = "FrontendIP1", Type = "Private" }; var frontEndPort1 = new FrontendPort { Name = "Port1", Port = 80, }; var probe1 = new Probe { Name = "Probe1", Protocol = "Http", Host = "127.0.0.1", Path = "/", Interval = 45, Timeout = 25, UnhealthyThreshold = 2 }; var backendServer1 = new BackendServer { IPAddress = "10.0.0.1", }; var backendServer2 = new BackendServer { IPAddress = "10.0.0.2", }; var backendAddressPool1 = new BackendAddressPool { Name = "Pool1", BackendServers = new List <BackendServer> { backendServer1, backendServer2 }, }; var backendHttpSettings1 = new BackendHttpSettings { Name = "Setting1", Port = 80, Protocol = Protocol.Http, CookieBasedAffinity = "Enabled", RequestTimeout = 45, Probe = "Probe1" }; var httpListener1 = new AGHttpListener { Name = "Listener1", FrontendPort = "Port1", Protocol = Protocol.Http, FrontendIP = "FrontendIP1", //SslCert = string.Empty, }; var httpLoadBalancingRule1 = new HttpLoadBalancingRule { Name = "Rule1", Type = "Basic", BackendHttpSettings = "Setting1", Listener = "Listener1", BackendAddressPool = "Pool1", }; config.FrontendIPConfigurations = new List <FrontendIPConfiguration> { frontEndIP1 }; config.FrontendPorts = new List <FrontendPort> { frontEndPort1 }; config.Probes = new List <Probe> { probe1 }; config.BackendAddressPools = new List <BackendAddressPool> { backendAddressPool1 }; config.BackendHttpSettingsList = new List <BackendHttpSettings> { backendHttpSettings1 }; config.HttpListeners = new List <AGHttpListener> { httpListener1 }; config.HttpLoadBalancingRules = new List <HttpLoadBalancingRule> { httpLoadBalancingRule1 }; return(config); }