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 IHttpActionResult StopServer([FromUri] HAProxyBackendServerRequest request = null) { return(PerformBackendServerAction(request, client => client.DisableServer(request?.BackendName, request?.Name))); }