using System.Linq; using System.Net; namespace ParadoxSaveParser.WebAPI.HttpHelpers; public class RequestHelper { internal static ValueOrError GetQueryValue(HttpListenerContext ctx, string paramName) { string[]? values = ctx.Request.QueryString.GetValues(paramName); string? value = values?.FirstOrDefault(); if (string.IsNullOrEmpty(value)) return new ErrorMessage(HttpStatusCode.BadRequest, $"No request parameter '{paramName}' provided"); return value; } }