From 29ff35801084359266c52c23bac3c266a83ac3c3 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sun, 23 Jun 2024 15:06:49 +1000 Subject: [PATCH] simplify acceptsJson --- src/Http/Wolverine.Http/HttpHandler.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Http/Wolverine.Http/HttpHandler.cs b/src/Http/Wolverine.Http/HttpHandler.cs index d5f1588fc..a6313ab16 100644 --- a/src/Http/Wolverine.Http/HttpHandler.cs +++ b/src/Http/Wolverine.Http/HttpHandler.cs @@ -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)]