Class WellKnownRoutesMiddleware

Namespace
Cratis.Arc.Http
Assembly
Cratis.Arc.Core.dll

Middleware for handling well-known routes (e.g., commands, queries).

public class WellKnownRoutesMiddleware : IHttpRequestMiddleware
Inheritance
WellKnownRoutesMiddleware
Implements
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the WellKnownRoutesMiddleware class.

Constructors

WellKnownRoutesMiddleware(IServiceProvider, ILogger<WellKnownRoutesMiddleware>)

Middleware for handling well-known routes (e.g., commands, queries).

public WellKnownRoutesMiddleware(IServiceProvider serviceProvider, ILogger<WellKnownRoutesMiddleware> logger)

Parameters

serviceProvider IServiceProvider

The service provider for request scoping.

logger ILogger<WellKnownRoutesMiddleware>

The logger for the middleware.

Remarks

Initializes a new instance of the WellKnownRoutesMiddleware class.

Methods

InvokeAsync(HttpListenerContext, HttpRequestDelegate)

Process an HTTP request.

public Task<bool> InvokeAsync(HttpListenerContext context, HttpRequestDelegate next)

Parameters

context HttpListenerContext

The HTTP listener context.

next HttpRequestDelegate

The next middleware in the pipeline.

Returns

Task<bool>

A task that represents the asynchronous operation, returning true if the request was handled, false otherwise.

RegisterRoute(string, string, Func<IHttpRequestContext, Task>, EndpointMetadata?)

Registers a route with the middleware.

public void RegisterRoute(string method, string pattern, Func<IHttpRequestContext, Task> handler, EndpointMetadata? metadata = null)

Parameters

method string

The HTTP method.

pattern string

The route pattern.

handler Func<IHttpRequestContext, Task>

The handler for the request.

metadata EndpointMetadata

Optional metadata for the endpoint.