refactored responses
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user