private static async Task GetApp(HttpListenerContext context) { var appid = context.Request.QueryString.Get("appid"); if (appid == null) { throw new MissingFieldException("appid parameter is missing"); } var result = await AppCommand.GetAppData(uint.Parse(appid)); if (result == null) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; await WriteJsonResponse("App not found", context.Response); return; } context.Response.ContentType = "text/vdf; charset=utf-8"; context.Response.Headers[HttpResponseHeader.ETag] = $"\"{Utils.ByteArrayToString(result.SHAHash)}\""; await using var kvMemory = new MemoryStream(); result.KeyValues.SaveToStream(kvMemory, false); kvMemory.Position = 0; await kvMemory.CopyToAsync(context.Response.OutputStream); }
private static async Task GetApp(HttpListenerContext context) { var appid = context.Request.QueryString.Get("appid"); if (appid == null) { throw new MissingFieldException("appid parameter is missing"); } var result = await AppCommand.GetAppData(uint.Parse(appid)); await WriteJsonResponse(result, context.Response); }