Skip to content

Commit

Permalink
Remove debug, fix content-type checker.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShroomAgent27 committed Mar 22, 2024
1 parent 4e3297e commit 006836e
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions WebHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ private void buildWebApp(string[] args)
Email email = await GetEmailAndSetResponse(context.Request, context.Response);
if (email is null)
{
Console.WriteLine("email object is null.");
return;
}
if (email.zipcode <= 0)
{
Console.WriteLine("Provided zipcode is 0 (or less).");
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
return;
}
Expand All @@ -71,7 +69,6 @@ private void buildWebApp(string[] args)
return;
handler.DeleteEmail(email);
context.Response.StatusCode = (int)HttpStatusCode.OK;

})
.WithName("DeleteEmail")
.WithOpenApi();
Expand All @@ -89,10 +86,8 @@ private void buildWebApp(string[] args)
private async Task<Email> GetEmailAndSetResponse(HttpRequest request, HttpResponse response)
{
Email email;
if (request.ContentType.Contains("application/json"))
if (!request.ContentType.Contains("application/json"))
{
Console.WriteLine("Invalid ContentType. ContentType is \"" + request.ContentType + "\"");
Console.WriteLine("No application/json in Header.");
response.StatusCode = (int)HttpStatusCode.BadRequest;
return null;
}
Expand All @@ -103,14 +98,11 @@ private async Task<Email> GetEmailAndSetResponse(HttpRequest request, HttpRespon
}
catch (Exception e)
{
Console.WriteLine("Exception decoding Json.");
Console.WriteLine(e.ToString());
response.StatusCode = (int)HttpStatusCode.BadRequest;
return null;
}
if (email is null || String.IsNullOrEmpty(email.email))
{
Console.WriteLine("Bad email.");
response.StatusCode = (int)HttpStatusCode.BadRequest;
return null;
}
Expand Down

0 comments on commit 006836e

Please sign in to comment.