2
0

actually use v2 API

This commit is contained in:
Glax 2024-04-19 22:20:24 +02:00
parent 2828fec316
commit f79743ee93
2 changed files with 10 additions and 13 deletions

View File

@ -68,7 +68,7 @@ public partial class Server : GlobalBase
if (request.Url!.LocalPath.Contains("favicon"))
SendResponse(HttpStatusCode.NoContent, response);
if (Regex.IsMatch(request.Url.LocalPath, ""))
if (Regex.IsMatch(request.Url.LocalPath, "/v2(/.*)?"))
{
HandleRequestV2(context);
return;

View File

@ -18,30 +18,27 @@ public partial class Server
ValueTuple<HttpStatusCode, object?> responseMessage = request.HttpMethod switch
{
"GET" => HandleGetV2(path, response, requestParams),
"POST" => HandlePostV2(path, response, requestParams),
"DELETE" => HandleDeleteV2(path, response, requestParams),
"GET" => HandleGetV2(path, requestParams),
"POST" => HandlePostV2(path, requestParams),
"DELETE" => HandleDeleteV2(path, requestParams),
_ => new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.MethodNotAllowed, null)
};
SendResponse(responseMessage.Item1, response, responseMessage.Item2);
}
private ValueTuple<HttpStatusCode, object?> HandleGetV2(string path, HttpListenerResponse response,
Dictionary<string, string> requestParameters)
private ValueTuple<HttpStatusCode, object?> HandleGetV2(string path, Dictionary<string, string> requestParameters)
{
throw new NotImplementedException("v2 not implemented yet");
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not implemented.");
}
private ValueTuple<HttpStatusCode, object?> HandlePostV2(string path, HttpListenerResponse response,
Dictionary<string, string> requestParameters)
private ValueTuple<HttpStatusCode, object?> HandlePostV2(string path, Dictionary<string, string> requestParameters)
{
throw new NotImplementedException("v2 not implemented yet");
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not implemented.");
}
private ValueTuple<HttpStatusCode, object?> HandleDeleteV2(string path, HttpListenerResponse response,
Dictionary<string, string> requestParameters)
private ValueTuple<HttpStatusCode, object?> HandleDeleteV2(string path, Dictionary<string, string> requestParameters)
{
throw new NotImplementedException("v2 not implemented yet");
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not implemented.");
}
}