Web Hosting
This is a simple library that allows you to add infrastructure to a WebApplicationBuilder
and post-app build against the WebApplication
to set all of the infrastructure up in one places.
This allows for modular chunks of code to install things like authentication, authorization, logging, etc. without having to add them to the main application startup code.
Features
Section titled “Features”- Merges service container build and post build scenarios into a single class
- All IInfrastructureModule implementations are automatically detected and run
-
Add an infrastructure module by implementing IInfrastructureModule:
using Shiny.Extensions.WebHosting;public class MyInfrastructureModule : IInfrastructureModule{public void Add(WebApplicationBuilder builder){// Register your services here}public void Configure(WebApplication app){// Configure your application here}} -
In your application hosting startup, add the following:
using Shiny.Extensions.WebHosting;var builder = WebApplication.CreateBuilder(args);builder.AddInfrastructure(params Assembly[] assemblies)(); // this scans the assemblies for IInfrastructureModule implementations and runs Add methods// ORbuilder.AddInfrastructureModules(params IInfrastructureModule[] modules); // this doesn't use reflectionvar app = builder.Build();app.UseInfrastructure(); // this runs all IInfrastructureModule.Use methods