private bool IsValid(HAProxyRequest request, out IHttpActionResult invalidResult) { if (request == null) { invalidResult = BadRequest(HAProxyRequest.HostNameOrIpAddressRequiredValidationMessage); return(false); } if (!request.Validate(out string errorMessage)) { invalidResult = BadRequest(errorMessage); return(false); } invalidResult = null; return(true); }
public IHttpActionResult GetStatus([FromUri] HAProxyRequest request = null) { if (!IsValid(request, out IHttpActionResult invalidResult)) { return(invalidResult); } if (request == null) { throw new InvalidOperationException(); } HaProxyClient client = request.CreateClient(); return(Ok(new { Backends = client.ShowBackends(), Servers = client.ShowBackendServers(), Info = client.ShowInfo(), Errors = client.ShowErrors() })); }