TiqriGlobalShop.Common.AspNetCore
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package TiqriGlobalShop.Common.AspNetCore --version 1.0.0
NuGet\Install-Package TiqriGlobalShop.Common.AspNetCore -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TiqriGlobalShop.Common.AspNetCore" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TiqriGlobalShop.Common.AspNetCore" Version="1.0.0" />
<PackageReference Include="TiqriGlobalShop.Common.AspNetCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TiqriGlobalShop.Common.AspNetCore --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TiqriGlobalShop.Common.AspNetCore, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TiqriGlobalShop.Common.AspNetCore@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TiqriGlobalShop.Common.AspNetCore&version=1.0.0
#tool nuget:?package=TiqriGlobalShop.Common.AspNetCore&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GlobalShop.Common.AspNetCore
Shared ASP.NET Core infrastructure for GlobalShop web APIs.
Features
Exception Handlers — Production-ready
IExceptionHandlerimplementations:CancellationExceptionHandler— Handles client-cancelled requests (HTTP 499)ConcurrencyExceptionHandler— Handles EF Core optimistic concurrency conflicts (HTTP 409)PostgresExceptionHandler— Maps PostgreSQL error codes to appropriate HTTP responsesDatabaseExceptionHandler— Handles general database connectivity errors (HTTP 503)GlobalExceptionHandler— Catch-all for unhandled exceptions (HTTP 500), with dev-mode details
Middleware
RequestContextLoggingMiddleware— Extracts/generatesX-Correlation-Idand pushes it into the SerilogLogContext
Minimal API Endpoints
IEndpoint— Interface for discoverable minimal API endpointsEndpointExtensions— Auto-discovers and mapsIEndpointimplementations from an assembly
Swagger / OpenAPI
SwaggerDefaultValues— Populates default API version parameters, deprecation markers, and response content typesApiVersionHeaderOperationFilter— Addsx-api-versionheader parameter to all Swagger operationsServiceCollectionExtensions.AddSwaggerGenWithJwtAuth()— Configures Swagger with JWT Bearer authentication, custom schema IDs, and operation filtersApplicationBuilderExtensions.UseSwaggerWithUi()— Enables Swagger + Swagger UI middleware
Result Pattern Helpers
ResultExtensions.Match()— Pattern-match onResult/Result<T>for railway-oriented endpoint handlersCustomResults.Problem()— ConvertsResultfailures to RFC 9457 Problem Details responses
JSON Patch
JsonPatchBinder<TModel>— Base class for model-bindingJsonPatchDocument<T>
Installation
dotnet add package GlobalShop.Common.AspNetCore
Quick Start
Register Exception Handlers
// In Program.cs or ConfigureServices
builder.Services.AddProblemDetails();
builder.Services.AddCommonExceptionHandlers(); // registers all 5 handlers
// ...
app.UseExceptionHandler();
Or register individual handlers:
builder.Services.AddExceptionHandler<CancellationExceptionHandler>();
builder.Services.AddExceptionHandler<GlobalExceptionHandler>();
Use Correlation ID Middleware
app.UseRequestContextLogging(); // adds X-Correlation-Id to Serilog LogContext
app.UseSerilogRequestLogging();
Discover Minimal API Endpoints
// Register
builder.Services.AddEndpoints(Assembly.GetExecutingAssembly());
// Map
app.MapEndpoints();
Implement endpoints:
public sealed class GetProducts : IEndpoint
{
public void MapEndpoint(IEndpointRouteBuilder app)
{
app.MapGet("/products", Handle);
}
private static async Task<IResult> Handle(/* dependencies */) { /* ... */ }
}
Swagger with JWT Auth
// In Program.cs — register your app-specific Swagger docs
builder.Services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
// Register generic JWT auth + operation filters
builder.Services.AddSwaggerGenWithJwtAuth();
Result Pattern Helpers
using GlobalShop.Common.AspNetCore.Extensions;
using GlobalShop.Common.AspNetCore.Results;
// In a minimal API endpoint handler
return result.Match(Results.Ok, CustomResults.Problem);
Swagger Filters
builder.Services.AddSwaggerGen(o =>
{
o.OperationFilter<SwaggerDefaultValues>();
o.OperationFilter<ApiVersionHeaderOperationFilter>();
});
Dependencies
| Package | Purpose |
|---|---|
GlobalShop.Common.SharedKernel |
Result/Error types for CustomResults and ResultExtensions |
Microsoft.AspNetCore.App (framework) |
Core ASP.NET types |
Microsoft.AspNetCore.Authentication.JwtBearer |
JWT Bearer auth for Swagger |
Microsoft.EntityFrameworkCore |
Concurrency/database exception handling |
Npgsql.EntityFrameworkCore.PostgreSQL |
PostgreSQL exception handling |
Serilog |
Log context for correlation IDs |
Swashbuckle.AspNetCore |
Swagger operation filters |
Asp.Versioning.Mvc.ApiExplorer |
API versioning support |
Microsoft.AspNetCore.JsonPatch |
JSON Patch model binding |
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.1)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.2)
- Microsoft.AspNetCore.JsonPatch (>= 10.0.2)
- Microsoft.EntityFrameworkCore (>= 10.0.1)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.0)
- Serilog (>= 4.3.0)
- Swashbuckle.AspNetCore (>= 10.1.1)
- TiqriGlobalShop.Common.SharedKernel (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.