Skip to main content
Version: 0.3.x (0.3.0)

Class ValueObjectProblemDetailsWorkerApplicationBuilderExtensions

Namespace: AdCodicem.ValueObjects.AzureFunctions.AspNetCore
Assembly: AdCodicem.ValueObjects.AzureFunctions.AspNetCore.dll

Registers the middleware that answers an HTTP trigger of the ASP.NET Core integration whose value objects the worker could not bind with RFC 9457 problem details carrying their rule codes.

public static class ValueObjectProblemDetailsWorkerApplicationBuilderExtensions

Inheritance​

object ← ValueObjectProblemDetailsWorkerApplicationBuilderExtensions

Inherited Members​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Methods​

UseValueObjectProblemDetails(IFunctionsWorkerApplicationBuilder)​

Answers an HTTP trigger whose value objects the worker could not bind with problem details carrying their rule codes.

public static IFunctionsWorkerApplicationBuilder UseValueObjectProblemDetails(this IFunctionsWorkerApplicationBuilder builder)

Parameters​

builder IFunctionsWorkerApplicationBuilder

The worker's builder.

Returns​

IFunctionsWorkerApplicationBuilder

The same builder, so calls can be chained.

Remarks​

Call it after ConfigureFunctionsWebApplication(), or inside ConfigureFunctionsWebApplication(worker => …): the integration's middleware, which writes the answer on the request, has to run outside this one. Called before, the failure keeps the worker's 500 and a warning is logged once. The built-in HTTP model, HttpRequestData without the integration, keeps the 500.

A refused route or query value is answered 400 with the shape WithValueObjectProblemDetails() writes on a minimal API: errors holds the message of each rule, errorCodes its code, keyed by the parameter's name; a required value object with no binding data is value_object.required. A [FromBody] value object is answered too where the MVC package's AddValueObjects() reads the body, keyed by its JSON path. A failure no value object explains, a plain among them, keeps the worker's 500. Each answer is logged once, with the parameters and their codes, never the values.

Calling it twice adds the middleware once.

Exceptions​

ArgumentNullException

builder is null.

UseValueObjectProblemDetails(IFunctionsWorkerApplicationBuilder, Action<ValueObjectMessageOptions>)​

Answers an HTTP trigger whose value objects the worker could not bind with problem details carrying their rule codes, with the messages the application's resource gives each code.

public static IFunctionsWorkerApplicationBuilder UseValueObjectProblemDetails(this IFunctionsWorkerApplicationBuilder builder, Action<ValueObjectMessageOptions> configure)

Parameters​

builder IFunctionsWorkerApplicationBuilder

The worker's builder.

configure Action<ValueObjectMessageOptions>

Names the resource the messages are read from, through .

Returns​

IFunctionsWorkerApplicationBuilder

The same builder, so calls can be chained.

Remarks​

The messages are read through the request's IStringLocalizerFactory, which builder.Services.AddLocalization() registers, in the culture UseRequestLocalization() chose when the application added it to the integration's pipeline, and otherwise in the one the application's RequestLocalizationOptions choose from the request, falling back to the current culture. A later call naming messages replaces those of an earlier one.

Exceptions​

ArgumentNullException

builder or configure is null.