private void GetOneProject(string slug, ApiRequest request) { try { var proj = _configurationService.GetProject(slug); var bytes = ConfigHashifier.Bytify(proj); request.Client.Send200_OK("application/json", bytes.Length); request.Client.Send(bytes, bytes.Length); } catch (ProjectDoesNotExistException) { request.Client.Send404_NotFound(); } }
private void HandleDefault(ApiRequest request) { if (request.HttpMethod == "GET") { var projects = _configurationService.GetProjects(); var bytes = ConfigHashifier.Bytify(projects); request.Client.Send200_OK("application/json", bytes.Length); request.Client.Send(bytes, bytes.Length); return; } if (request.HttpMethod == "PUT") { var proj = new ProjectModel(); UnpackProject(request, proj); proj.Slug = ""; _configurationService.SaveProject(proj); request.Client.Send200_OK("application/json"); return; } request.Client.Send405_MethodNotAllowed(); }