Change Method Header for Handlers to return the response to HandleRequest so we don't forget to send a response.
This commit is contained in:
parent
595051b0fe
commit
d22b49cfa8
@ -18,22 +18,15 @@ public partial class Server
|
|||||||
Dictionary<string, string> requestParams = requestVariables.UnionBy(requestBody, v => v.Key)
|
Dictionary<string, string> requestParams = requestVariables.UnionBy(requestBody, v => v.Key)
|
||||||
.ToDictionary(kv => kv.Key, kv => kv.Value); //The actual variable used for the API
|
.ToDictionary(kv => kv.Key, kv => kv.Value); //The actual variable used for the API
|
||||||
|
|
||||||
|
ValueTuple<HttpStatusCode, object?> responseMessage = request.HttpMethod switch
|
||||||
switch (request.HttpMethod)
|
|
||||||
{
|
{
|
||||||
case "GET":
|
"GET" => HandleGetV2(path, response, requestParams),
|
||||||
HandleGetV2(path, response, requestParams);
|
"POST" => HandlePostV2(path, response, requestParams),
|
||||||
break;
|
"DELETE" => HandleDeleteV2(path, response, requestParams),
|
||||||
case "POST":
|
_ => new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.MethodNotAllowed, null)
|
||||||
HandlePostV2(path, response, requestParams);
|
};
|
||||||
break;
|
|
||||||
case "DELETE":
|
SendResponse(responseMessage.Item1, response, responseMessage.Item2);
|
||||||
HandleDeleteV2(path, response, requestParams);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SendResponse(HttpStatusCode.MethodNotAllowed, response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, string> GetRequestBody(HttpListenerRequest request)
|
private Dictionary<string, string> GetRequestBody(HttpListenerRequest request)
|
||||||
@ -60,19 +53,19 @@ public partial class Server
|
|||||||
return new Dictionary<string, string>();
|
return new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleGetV2(string path, HttpListenerResponse response,
|
private ValueTuple<HttpStatusCode, object?> HandleGetV2(string path, HttpListenerResponse response,
|
||||||
Dictionary<string, string> requestParameters)
|
Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("v2 not implemented yet");
|
throw new NotImplementedException("v2 not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandlePostV2(string path, HttpListenerResponse response,
|
private ValueTuple<HttpStatusCode, object?> HandlePostV2(string path, HttpListenerResponse response,
|
||||||
Dictionary<string, string> requestParameters)
|
Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("v2 not implemented yet");
|
throw new NotImplementedException("v2 not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleDeleteV2(string path, HttpListenerResponse response,
|
private ValueTuple<HttpStatusCode, object?> HandleDeleteV2(string path, HttpListenerResponse response,
|
||||||
Dictionary<string, string> requestParameters)
|
Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("v2 not implemented yet");
|
throw new NotImplementedException("v2 not implemented yet");
|
||||||
|
Loading…
Reference in New Issue
Block a user