Skip to content

Commit

Permalink
feat: pass IApplicationContext to ConfigureWebHostDefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicGD committed Apr 4, 2023
1 parent 0db6be5 commit 845175b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/Sitko.Core.App.Web/WebApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,19 @@ protected override void ConfigureHostBuilder(IHostBuilder builder)
});
}

protected override void PostConfigureHostBuilder(IHostBuilder hostBuilder)
protected override void PostConfigureHostBuilder(IApplicationContext applicationContext, IHostBuilder hostBuilder)
{
base.PostConfigureHostBuilder(hostBuilder);
base.PostConfigureHostBuilder(applicationContext, hostBuilder);
hostBuilder.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseSetting("ApplicationId", Id.ToString());
webBuilder.UseStartup<TStartup>();
ConfigureWebHostDefaults(webBuilder);
ConfigureWebHostDefaults(applicationContext, webBuilder);
});
}

protected virtual void ConfigureWebHostDefaults(IWebHostBuilder webHostBuilder)
protected virtual void ConfigureWebHostDefaults(IApplicationContext applicationContext,
IWebHostBuilder webHostBuilder)
{
}

Expand Down Expand Up @@ -143,4 +144,3 @@ public static TWebApplication Run<TWebApplication, TStartup>(this TWebApplicatio
return application;
}
}

4 changes: 2 additions & 2 deletions src/Sitko.Core.App/HostedApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ protected IHostBuilder ConfigureHostBuilder(Action<IHostBuilder>? configure = nu
});
});
configure?.Invoke(hostBuilder);
PostConfigureHostBuilder(hostBuilder);
PostConfigureHostBuilder(bootApplicationContext, hostBuilder);
LogInternal("Create host builder done");
return hostBuilder;
}

protected virtual void PostConfigureHostBuilder(IHostBuilder hostBuilder)
protected virtual void PostConfigureHostBuilder(IApplicationContext applicationContext, IHostBuilder hostBuilder)
{
}

Expand Down
6 changes: 4 additions & 2 deletions src/Sitko.Core.Xunit.Web/WebTestApplication.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Sitko.Core.App;
using Sitko.Core.App.Web;

namespace Sitko.Core.Xunit.Web;
Expand All @@ -10,9 +11,10 @@ protected WebTestApplication(string[] args) : base(args)
{
}

protected override void ConfigureWebHostDefaults(IWebHostBuilder webHostBuilder)
protected override void ConfigureWebHostDefaults(IApplicationContext applicationContext,
IWebHostBuilder webHostBuilder)
{
base.ConfigureWebHostDefaults(webHostBuilder);
base.ConfigureWebHostDefaults(applicationContext, webHostBuilder);
webHostBuilder.UseTestServer();
}
}
Expand Down
7 changes: 4 additions & 3 deletions tests/Sitko.Core.Grpc.Server.Tests/TestApplication.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Sitko.Core.App;
using Sitko.Core.App.Web;

namespace Sitko.Core.Grpc.Server.Tests;
Expand All @@ -12,10 +13,10 @@ public TestApplication(string[] args) : base(args) =>
moduleOptions.RegisterService<GrpcTestService>();
});

protected override void ConfigureWebHostDefaults(IWebHostBuilder webHostBuilder)
protected override void ConfigureWebHostDefaults(IApplicationContext applicationContext,
IWebHostBuilder webHostBuilder)
{
base.ConfigureWebHostDefaults(webHostBuilder);
base.ConfigureWebHostDefaults(applicationContext, webHostBuilder);
webHostBuilder.UseTestServer();
}
}

0 comments on commit 845175b

Please sign in to comment.