private void GoPut(HttpListenerContext context) { var id = uint.Parse(context.Request.Url.AbsolutePath.Substring(1)); if (_endpointDb.Fetch(id) == null) { utils.SetStatus(context, HttpStatusCode.NotFound); return; } var data = utils.ReadPost(context.Request); IList <Endpoint> parsed; try { parsed = YamlParser.FromString(data); } catch { utils.SetStatus(context, HttpStatusCode.BadRequest); return; } if (parsed.Count != 1) { Unprocessable(context); return; } _endpointDb.Replace(id, parsed[0]); }
/// <summary> /// Swap out the configuration of one of the endpoints /// </summary> /// <param name="id">The id of the endpoint to replace</param> /// <param name="endpoint">The new endpoint data</param> /// <returns>True if the operation succeeded</returns> public bool Replace(uint id, Endpoint endpoint) { return(_endpointDb.Replace(id, endpoint)); }