WebApiController: Fix return value mapping
ln.build - build0.waldrennach.l--n.de build job pending
Details
ln.build - build0.waldrennach.l--n.de build job pending
Details
parent
133656cad1
commit
7faf05f4aa
|
@ -4,6 +4,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ln.http.api.attributes;
|
||||
using ln.http.exceptions;
|
||||
using ln.http.router;
|
||||
|
@ -46,17 +47,16 @@ namespace ln.http.api
|
|||
|
||||
object result = methodInfo.Invoke(this, arguments);
|
||||
|
||||
if (!methodInfo.ReturnType.Equals(typeof(HttpResponse)))
|
||||
{
|
||||
if (!typeof(JSONValue).IsAssignableFrom(methodInfo.ReturnType))
|
||||
{
|
||||
if (!JSONMapper.DefaultMapper.Serialize(result, out JSONValue json))
|
||||
return HttpResponse.InternalServerError().Content("Method result could not be serialized");
|
||||
|
||||
result = json;
|
||||
}
|
||||
return defaultResponseFactory().Content((JSONValue)result);
|
||||
}
|
||||
if (result is HttpResponse httpResponse)
|
||||
return httpResponse;
|
||||
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -20,3 +20,4 @@
|
|||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
|
|
Loading…
Reference in New Issue