fix: register api explorer in sandbox host

This commit is contained in:
Meik
2026-07-01 01:20:19 +02:00
parent f84d840e51
commit d1b41814a2
4 changed files with 46 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<host xmlns="urn:m42/host.config">
<modules>
<module assembly="C4ITF4SDM42WebApi" />
<module assembly="Matrix42.DataLayer.Persistence" />
<module assembly="Matrix42.Services.WebApi" />
<module assembly="Matrix42.ServiceRepository.BizLogic" />

View File

@@ -13,7 +13,7 @@
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<M42ExtensionId>6673a25d-33d6-4072-91d9-abed4be1a966</M42ExtensionId>
<M42AssemblyPattern>C4ITF4SD*.*</M42AssemblyPattern>
<M42PackageVersion>1.4.0.32</M42PackageVersion>
<M42PackageVersion>1.4.0.33</M42PackageVersion>
<M42BuildPackage>true</M42BuildPackage>
</PropertyGroup>
@@ -66,6 +66,10 @@
<HintPath>M42Libraries\26.1\System.Net.Http.Formatting.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="System.Web.Http">
<HintPath>M42Libraries\26.1\System.Web.Http.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="update4u.SPS.DataLayer">
<HintPath>M42Libraries\26.1\update4u.SPS.DataLayer.dll</HintPath>
<Private>false</Private>
@@ -82,6 +86,7 @@
<ItemGroup>
<Compile Include="cM42LogEntry.cs" />
<Compile Include="F4SDM42DependencyRegistrator.cs" />
<Compile Include="F4SDHelperService.cs" />
<Compile Include="F4SDM42WebApiController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -0,0 +1,38 @@
using System;
using System.Web.Http;
using System.Web.Http.Description;
using Matrix42.Hosting.Contracts;
using C4IT.Logging;
using static C4IT.Logging.cLogManager;
namespace C4IT.F4SD
{
public class F4SDM42DependencyRegistrator : IDependencyRegistrator
{
public void Register(IDependencyContainer container, IDependencyResolver resolver)
{
if (container == null)
throw new ArgumentNullException(nameof(container));
if (resolver == null)
throw new ArgumentNullException(nameof(resolver));
try
{
if (resolver.TryGet(typeof(IApiExplorer)) != null)
return;
}
catch
{
// Existing mapping is incomplete in the sandbox host. Register a concrete instance below.
}
var httpConfiguration = new HttpConfiguration();
container.RegisterInstance(typeof(IApiExplorer), new ApiExplorer(httpConfiguration));
LogEntry("Registered System.Web.Http.Description.IApiExplorer for Matrix42 sandbox host.", LogLevels.Debug);
}
}
}

View File

@@ -308,7 +308,7 @@ namespace C4IT.F4SD
Values = vals.ToArray()
};
//CacheOutputAttribute.RegisterResponseEtag($"enum_{enumeration.Name}_{(int)mode}", $"{enumeration.Name}_{(int)mode}", cultureInvariant: false, userInvariant: true, val);
return Request.CreateResponse(HttpStatusCode.OK, enumeration);
return Matrix42.WebApi.Contracts.HttpResponseExtensions.CreateResponse(Request, HttpStatusCode.OK, enumeration);
}
[Route("getMyRoleMemberships"), HttpGet]