Update to latest packages and show examples

This commit is contained in:
2026-07-05 22:05:53 +02:00
parent 3a36978997
commit c7ddc282ed
52 changed files with 2156 additions and 21 deletions
+33 -1
View File
@@ -6,7 +6,7 @@ This solution demonstrates all features of the GerstITS framework packages in a
| Project | Purpose |
|---------|---------|
| `GerstITS.Examples.Api` | ASP.NET Core Web API host: fluent controllers, versioning, exception handling, Swagger, authentication, session cache, jobs and auto migration. |
| `GerstITS.Examples.Api` | ASP.NET Core Web API host: fluent controllers, minimal API endpoints, versioning, exception handling, Swagger, authentication, session cache, jobs and auto migration. |
| `GerstITS.Examples.Logic` | Business logic: providers, search engine integration, validation rules, customizations and AutoMapper profiles. |
| `GerstITS.Examples.Data` | Data access: entities with framework aspects, EF Core DbContext, entity mappings, database configurator and migrations. |
| `GerstITS.Examples.Jobs.SayHelloWorld` | Scheduled Quartz jobs with cron configuration. |
@@ -80,6 +80,7 @@ This solution demonstrates all features of the GerstITS framework packages in a
| `ValidationRuleBase<T>` (FluentValidation) | `Logic/Customers/Validation/CustomerValidationRule.cs`, `Logic/Shared/Validation/IdValidationRule.cs` |
| `IsEMail()` rule builder extension | `CustomerValidationRule.cs` |
| Automatic validation in fluent controllers (`IValidator`) | All controllers via `FluentApiControllerBase` |
| Explicit validation in minimal API endpoints (`IValidator` + `ToErrorMessage`) | `Api/Endpoints/Endpoints.Validator.cs` |
### GerstITS.Mapping.AutoMapper
| Feature | Example |
@@ -92,7 +93,12 @@ This solution demonstrates all features of the GerstITS framework packages in a
| `HostingStartup` fluent pipeline | `Api/Program.cs` |
| `FluentApiControllerBase` (`Api().Use(...).Get/Create/Update/Delete`) | `Api/Controllers/1.1/*.cs` |
| API versioning (side by side controllers) | `Api/Controllers/1.0` vs `Api/Controllers/1.1` |
| Minimal API endpoints (partial `Endpoints` class per feature, nested static endpoint classes) | `Api/Endpoints/Endpoints.cs`, `Endpoints.Customers.cs`, `Endpoints.CustomerNotes.cs` |
| Endpoint grouping + Swagger tags (`MapGroup`, `WithTags`) | `Api/Endpoints/Endpoints.Customers.cs` |
| Query parameter binding to search filters (`[AsParameters]`) | `Endpoints.Customers.MapSearch` |
| Global exception transformations | `Api/Common/ExceptionHandling/Transformations/*.cs` |
| Global exception handling middleware for minimal APIs (`UseGlobalExceptionHandling`) | `Api/Common/ExceptionHandling/Extensions/WebApplicationExtensions.cs`, `Api/Program.cs` |
| Automatic response compression (zstd, brotli, gzip — also for HTTPS) | built in, no app code required — see "Response compression" below |
| Server configuration (CORS, HSTS, forwarded headers) | `Api/Common/Configurations/WebApiConfiguration.Server.*.cs` |
| Swagger configuration incl. security schemes | `Api/Common/Configurations/WebApiConfiguration.Swagger*.cs`, `WebApiConfiguration.OpenApiSecurityScheme.cs` |
| Session based cache storage (`AddHttpSession`) | `Api/Module.Session.cs`, `CacheController.cs` |
@@ -133,6 +139,32 @@ This solution demonstrates all features of the GerstITS framework packages in a
4. **Tests**: `dotnet test` (optionally `--filter "Category=Unit"`).
5. **Migrations**: `dotnet ef migrations add <Name>` inside `GerstITS.Examples.Data` (uses the design time factory and `appsettings.json` of that project).
### Fluent controllers vs. minimal API endpoints
The customer domain is exposed twice to compare both styles:
- `POST/GET/PUT/DELETE /api/Customer` — fluent controllers (`FluentApiControllerBase`, validation and exception transformations applied by the fluent pipeline).
- `GET/POST/PUT/DELETE /api/v2.0/customers` — minimal API endpoints (partial `Endpoints` class, explicit `Endpoints.Validator`, exception transformations applied by `UseGlobalExceptionHandling`).
Search differs on purpose: the controller uses `POST /api/Customer/Search` with a body filter, the minimal API uses
`GET /api/v2.0/customers` binding the same `CustomerSearchFilter` from query parameters via `[AsParameters]`.
### Response compression
`GerstITS.Web.Api` enables response compression automatically — there is nothing to register or configure in the
application: the framework module registers the zstd (`ZstdSharp`), brotli and gzip providers with
`EnableForHttps = true` and `HostingStartup...Build()` adds the `UseResponseCompression()` middleware. The provider is
picked by the client's `Accept-Encoding` header (zstd preferred, then brotli, then gzip):
```
curl -s -D - -o NUL -H "Accept-Encoding: zstd, br, gzip" https://localhost:<port>/api/v2.0/customers
```
The response then carries the matching `Content-Encoding` header (e.g. `Content-Encoding: zstd`).
> Requires the first `GerstITS.Web.Api` release after 2026.7.7 — older packages do not contain the compression
> feature yet, requests are then answered uncompressed.
### Api key protected endpoints
`GET /api/Maintenance/Ping` requires the header configured under `WebApi:ApiKey` (default: `X-Api-Key: example-api-key`).