Fixed Content-Type of web api mapping returning JSON
ln.build - build0.waldrennach.l--n.de build job pending Details

master
Harald Wolff 2020-12-12 20:56:10 +01:00
parent c3371bb0d8
commit f73d32f066
1 changed files with 7 additions and 6 deletions

View File

@ -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<HttpResponse> defaultRepsonseFactory)