Class ValueObjectHttpServiceCollectionExtensions
Namespace: AdCodicem.ValueObjects.AspNetCore.Http
Assembly: AdCodicem.ValueObjects.AspNetCore.Http.dll
Registers what answers a value object a minimal API could not bind when the binder throws instead of answering.
public static class ValueObjectHttpServiceCollectionExtensions
Inheritance
object ← ValueObjectHttpServiceCollectionExtensions
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Methods
AddValueObjectHttpProblemDetails(IServiceCollection)
Registers the exception handler that answers a refused value object with problem details carrying the code of
its rule when RouteHandlerOptions.ThrowOnBadRequest is on.
public static IServiceCollection AddValueObjectHttpProblemDetails(this IServiceCollection services)
Parameters
services IServiceCollection
The application's services.
Returns
The same services, so calls can be chained.
Remarks
With ThrowOnBadRequest on, the default in Development, a minimal API throws a
ThrowOnBadRequest off, the framework answers such a body before any filter
runs, and the handler keeps that answer. On an endpoint whose convention names a resource of messages, the handler
answers with them, in the culture of the request, whatever the order of UseRequestLocalization() and
UseExceptionHandler().
It is an AddProblemDetails() and call app.UseExceptionHandler() wherever ThrowOnBadRequest is on.
Handlers run in the order they were registered, so register it before a handler that answers every exception.
Registering it twice registers it once.
Exceptions
services is null.