Skip to content

DI Extensions ​

Extensions from Gryd.API for dependency injection and the HTTP pipeline.

Service registration ​

AddGrydCore(...) ​

AddGrydCore registers MediatR handlers and FluentValidation validators from the supplied assemblies, Gryd pipeline behaviors, and IDateTimeService. Use it when composing application assemblies yourself. The maintained API templates show a complete host composition; module registrations remain separate. See MediatR pipeline behaviors for registration order and scan behavior.

csharp
using Gryd.API.Extensions;

builder.Services.AddGrydCore(typeof(Program).Assembly);

AddCoreExceptionHandler() ​

Registers the fallback exception handler for ASP.NET Core's unified exception pipeline:

csharp
using Gryd.API.Extensions;

builder.Services.AddCoreExceptionHandler();

Application pipeline ​

UseCorrelationId() ​

Adds request and response correlation headers (X-Correlation-ID and X-Request-ID).

UseGryd() ​

Convenience extension that applies correlation and UseExceptionHandler(). Register exception handlers first, for example with AddCoreExceptionHandler() or a module handler plus the Core fallback. Call it after building the app; use the individual middleware methods when the host needs to control their order.

csharp
app.UseGryd();

For a full registration and middleware example, see the maintained gryd-minimal template.

Released under the MIT License.