17 lines
560 B
C#
17 lines
560 B
C#
using System.Linq;
|
|
using System.Net;
|
|
|
|
namespace ParadoxSaveParser.WebAPI.HttpHelpers;
|
|
|
|
public class RequestHelper
|
|
{
|
|
internal static ValueOrError<string> 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;
|
|
}
|
|
} |