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.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using ln.http.api.attributes;
|
using ln.http.api.attributes;
|
||||||
using ln.http.exceptions;
|
using ln.http.exceptions;
|
||||||
using ln.http.router;
|
using ln.http.router;
|
||||||
|
@ -46,17 +47,16 @@ namespace ln.http.api
|
||||||
|
|
||||||
object result = methodInfo.Invoke(this, arguments);
|
object result = methodInfo.Invoke(this, arguments);
|
||||||
|
|
||||||
if (!methodInfo.ReturnType.Equals(typeof(HttpResponse)))
|
if (result is HttpResponse httpResponse)
|
||||||
{
|
return httpResponse;
|
||||||
if (!typeof(JSONValue).IsAssignableFrom(methodInfo.ReturnType))
|
|
||||||
{
|
if (result is JSONValue jsonResult)
|
||||||
if (!JSONMapper.DefaultMapper.Serialize(result, out JSONValue json))
|
return defaultResponseFactory().Content(jsonResult);
|
||||||
return HttpResponse.InternalServerError().Content("Method result could not be serialized");
|
|
||||||
|
if (!JSONMapper.DefaultMapper.Serialize(result, out JSONValue json))
|
||||||
result = json;
|
return HttpResponse.InternalServerError().Content("Method result could not be serialized");
|
||||||
}
|
|
||||||
return defaultResponseFactory().Content((JSONValue)result);
|
result = json;
|
||||||
}
|
|
||||||
|
|
||||||
return defaultResponseFactory().Content(result.ToString());
|
return defaultResponseFactory().Content(result.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,3 +20,4 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue