Interface IEndpointMapper

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

Defines a system that can map HTTP endpoints for commands and queries.

public interface IEndpointMapper
Extension Methods

Methods

EndpointExists(string)

Checks if an endpoint with the given name already exists.

bool EndpointExists(string name)

Parameters

name string

The endpoint name.

Returns

bool

True if the endpoint exists.

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

Maps a GET endpoint.

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

Parameters

pattern string

The route pattern.

handler Func<IHttpRequestContext, Task>

The handler for the request.

metadata EndpointMetadata

Optional metadata for the endpoint (tags, name, etc.).

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

Maps an endpoint for the given HTTP method.

void MapMethod(string httpMethod, string pattern, Func<IHttpRequestContext, Task> handler, EndpointMetadata? metadata = null)

Parameters

httpMethod string

The HTTP method (e.g. GET, POST, QUERY) to map.

pattern string

The route pattern.

handler Func<IHttpRequestContext, Task>

The handler for the request.

metadata EndpointMetadata

Optional metadata for the endpoint (tags, name, etc.).

Remarks

This is the general extension point for mapping endpoints — new HTTP methods (such as QUERY) are supported by passing the method token, without changing the callers. The default implementation dispatches GET and POST to MapGet(string, Func<IHttpRequestContext, Task>, EndpointMetadata?) and MapPost(string, Func<IHttpRequestContext, Task>, EndpointMetadata?) and ignores any other method; implementers that support additional verbs (such as QUERY) override this.

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

Maps a POST endpoint.

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

Parameters

pattern string

The route pattern.

handler Func<IHttpRequestContext, Task>

The handler for the request.

metadata EndpointMetadata

Optional metadata for the endpoint (tags, name, etc.).