From f73d32f066a72c857216c4c46f1b4d428c9059c9 Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Sat, 12 Dec 2020 20:56:10 +0100 Subject: [PATCH] Fixed Content-Type of web api mapping returning JSON --- ln.http.api/WebApiController.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ln.http.api/WebApiController.cs b/ln.http.api/WebApiController.cs index c74ca9a..eab368b 100644 --- a/ln.http.api/WebApiController.cs +++ b/ln.http.api/WebApiController.cs @@ -53,12 +53,13 @@ namespace ln.http.api if (result is JSONValue jsonResult) return defaultResponseFactory().Content(jsonResult); - if (!JSONMapper.DefaultMapper.Serialize(result, out JSONValue json)) - return HttpResponse.InternalServerError().Content("Method result could not be serialized"); - - result = json; - - return defaultResponseFactory().Content(result.ToString()); + if (JSONMapper.DefaultMapper.Serialize(result, out JSONValue json)) + return defaultResponseFactory() + .ContentType("application/json") + .Content(result.ToString()) + ; + + return HttpResponse.InternalServerError().Content("Method result could not be serialized"); } void MapArguments(HttpRequest request, MethodInfo methodInfo,out object[] arguments, out Func defaultRepsonseFactory)