Skip to content

Commit

Permalink
simplify acceptsJson
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jun 23, 2024
1 parent 4ad9781 commit 29ff358
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/Http/Wolverine.Http/HttpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,12 @@ private static bool acceptsJson(HttpContext context)
{
var headers = new RequestHeaders(context.Request.Headers);

if (!headers.Accept.Any())
{
return true;
}

if (headers.Accept.Any(x => x.MediaType.HasValue && (x.MediaType.Value == "application/json" || x.MediaType.Value == "*/*" || x.MediaType.Value == "text/json")))
{
return true;
}

return false;
return headers.Accept
.Any(x => x.MediaType is
{
HasValue: true,
Value: "application/json" or "*/*" or "text/json"
});
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down

0 comments on commit 29ff358

Please sign in to comment.