fix: return native web api responses

This commit is contained in:
Meik
2026-07-01 09:44:48 +02:00
parent 80265ec1da
commit 6cb9e3b5fd
3 changed files with 26 additions and 8 deletions

View File

@@ -13,7 +13,7 @@
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<M42ExtensionId>6673a25d-33d6-4072-91d9-abed4be1a966</M42ExtensionId> <M42ExtensionId>6673a25d-33d6-4072-91d9-abed4be1a966</M42ExtensionId>
<M42AssemblyPattern>C4ITF4SD*.*</M42AssemblyPattern> <M42AssemblyPattern>C4ITF4SD*.*</M42AssemblyPattern>
<M42PackageVersion>1.4.0.36</M42PackageVersion> <M42PackageVersion>1.4.0.37</M42PackageVersion>
<M42BuildPackage>true</M42BuildPackage> <M42BuildPackage>true</M42BuildPackage>
</PropertyGroup> </PropertyGroup>

View File

@@ -210,7 +210,7 @@ namespace C4IT.F4SD
*/ */
[Route("getPickup/{name}"), HttpGet] [Route("getPickup/{name}"), HttpGet]
//[CacheOutput(UseETAG = true)] //[CacheOutput(UseETAG = true)]
public async Task<HttpResponseMessage> getPickup(string name, EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, Int32 group = -1) public async Task<EntityEnumeration> getPickup(string name, EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, Int32 group = -1)
{ {
await Task.Delay(0); await Task.Delay(0);
EntityEnumeration enumerationTemp = GetEnumeration(name, mode); EntityEnumeration enumerationTemp = GetEnumeration(name, mode);
@@ -233,7 +233,7 @@ namespace C4IT.F4SD
Values = vals.ToArray() Values = vals.ToArray()
}; };
//CacheOutputAttribute.RegisterResponseEtag($"enum_{enumeration.Name}_{(int)mode}", $"{enumeration.Name}_{(int)mode}", cultureInvariant: false, userInvariant: true, val); //CacheOutputAttribute.RegisterResponseEtag($"enum_{enumeration.Name}_{(int)mode}", $"{enumeration.Name}_{(int)mode}", cultureInvariant: false, userInvariant: true, val);
return Matrix42.WebApi.Contracts.HttpResponseExtensions.CreateResponse(Request, HttpStatusCode.OK, enumeration); return enumeration;
} }
[Route("getMyRoleMemberships"), HttpGet] [Route("getMyRoleMemberships"), HttpGet]
@@ -395,9 +395,9 @@ namespace C4IT.F4SD
} }
[Route("isAlive"), HttpGet] [Route("isAlive"), HttpGet]
public HttpResponseMessage isAlive() public IHttpActionResult isAlive()
{ {
return new HttpResponseMessage(HttpStatusCode.NoContent); return new StatusCodeResult(HttpStatusCode.NoContent);
} }
[Route("loglevel"), HttpGet] [Route("loglevel"), HttpGet]
@@ -423,16 +423,20 @@ namespace C4IT.F4SD
} }
[Route("log"), HttpGet] [Route("log"), HttpGet]
public HttpResponseMessage getLog(string download = "0", int count = 50, string filter = "") public IHttpActionResult getLog(string download = "0", int count = 50, string filter = "")
{ {
try try
{ {
return _f4stHelperService.privGetLog(download, count, Request, filter); var response = _f4stHelperService.privGetLog(download, count, Request, filter);
if (response == null)
return new StatusCodeResult(HttpStatusCode.NoContent);
return new ResponseMessageResult(response);
} }
catch (Exception E) catch (Exception E)
{ {
LogException(E); LogException(E);
return null; return new StatusCodeResult(HttpStatusCode.InternalServerError);
} }
} }
} }

View File

@@ -37,6 +37,20 @@
" pm.response.to.be.json;", " pm.response.to.be.json;",
" }", " }",
" });", " });",
"",
" const contentType = pm.response.headers.get(\"Content-Type\") || \"\";",
" if (contentType.toLowerCase().includes(\"json\")) {",
" const json = pm.response.json();",
" const isSerializedHttpResponse = json && !Array.isArray(json) &&",
" Object.prototype.hasOwnProperty.call(json, \"Version\") &&",
" Object.prototype.hasOwnProperty.call(json, \"Content\") &&",
" Object.prototype.hasOwnProperty.call(json, \"StatusCode\") &&",
" Object.prototype.hasOwnProperty.call(json, \"IsSuccessStatusCode\");",
"",
" pm.test(\"Response is not a serialized HttpResponseMessage\", function () {",
" pm.expect(isSerializedHttpResponse).to.equal(false);",
" });",
" }",
"}" "}"
] ]
} }