ControllerInstaller — Web
Key: Controller
Default Enabled: ✅
Package: SaveApis.Framework.Web
Purpose
Registers ASP.NET Core MVC controllers, adds controller application parts from the configured assemblies, configures JSON serialization for enums, and maps all controllers with global RequireAuthorization() in the pipeline.
What It Does
Builder phase:
- Configures
JsonStringEnumConverterfor all HTTP JSON responses (enums are serialized as strings) - Calls
builder.Services.AddControllers() - Adds
context.SoftwareAssemblyas a controller application part - Adds all assemblies from
context.Assembliesas additional controller application parts
Application phase:
- Calls
app.MapControllers().RequireAuthorization()— maps all controller routes and requires authorization by default
Dependencies
| Dependency | Direction | Requirement | Description |
|---|---|---|---|
AuthenticationInstaller |
After | Optional | Auth middleware should be present for RequireAuthorization() |
AuthorizationInstaller |
After | Optional | Authorization services must be registered |
ZitadelInstaller |
After | Optional | Zitadel scheme should be registered before controllers are mapped |
OpenApiInstaller |
Before | Optional | OpenAPI should run after controllers are registered |
ScalarInstaller |
Before | Optional |
Configuration
This installer has no configuration options.
Assembly selection is controlled via the InstallerContext:
(app, installer) =>
{
installer.SetSoftwareAssembly(); // required: scans entry assembly for controllers
installer.AddAssembly(typeof(SomeController)); // optional: include controllers from other assemblies
}
InstallerContext Extension
installer.WithControllers(bool enabled = true);
Notes
SetSoftwareAssembly()is required. Without it, no controllers from your application are registered and the installer will throw whenSoftwareAssemblyis accessed.- All controller routes are protected by
RequireAuthorization()globally. Use[AllowAnonymous]on specific actions to opt out. - Enums are always serialized as strings in JSON responses and accepted as strings in JSON request bodies. This is applied via
ConfigureHttpJsonOptions.
Related
- Web Framework Overview
- AuthorizationInstaller — provides the authorization services used by
RequireAuthorization() - OpenApiInstaller — generates the OpenAPI document from the registered controllers