Class RoutingModuleBase
Base class for modules that handle requests by resolving route / method pairs associated with handlers.
Inherited Members
Namespace: EmbedIO.Routing
Syntax
public abstract class RoutingModuleBase : WebModuleBase, IWebModuleImpl, IWebModule
Constructors
RoutingModuleBase(String)
Initializes a new instance of the Routing
Declaration
protected RoutingModuleBase(string baseRoute)
Parameters
Type | Name | Description |
---|---|---|
String | baseRoute | The base route served by this module. |
See Also
Properties
IsFinalHandler
Gets a value indicating whether processing of a request should stop after a module has handled it.
Declaration
public override bool IsFinalHandler { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
Remarks
If this property is true, a HTTP context's
Set
See Also
Methods
AddHandler(HttpVerb, RouteMatcher, RouteHandlerCallback)
Associates a HTTP method and a route to a handler.
Declaration
protected void AddHandler(HttpVerb verb, RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Http |
verb | A Http |
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
AddHandler(HttpVerb, RouteMatcher, SyncRouteHandlerCallback)
Associates a HTTP method and a route to a synchronous handler.
Declaration
protected void AddHandler(HttpVerb verb, RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Http |
verb | A Http |
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
AddHandlersFrom(Object)
Adds handlers, associating them with HTTP method / route pairs by means
of Route
See Add
Declaration
protected int AddHandlersFrom(object target)
Parameters
Type | Name | Description |
---|---|---|
Object | target | Where to look for compatible handlers. |
Returns
Type | Description |
---|---|
Int32 | The number of handlers that were added. |
OnAny(RouteMatcher, RouteHandlerCallback)
Associates all requests matching a route to a handler.
Declaration
protected void OnAny(RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
OnAny(RouteMatcher, SyncRouteHandlerCallback)
Associates all requests matching a route to a synchronous handler.
Declaration
protected void OnAny(RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
OnDelete(RouteMatcher, RouteHandlerCallback)
Associates DELETE
requests matching a route to a handler.
Declaration
protected void OnDelete(RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
OnDelete(RouteMatcher, SyncRouteHandlerCallback)
Associates DELETE
requests matching a route to a synchronous handler.
Declaration
protected void OnDelete(RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
OnGet(RouteMatcher, RouteHandlerCallback)
Associates GET
requests matching a route to a handler.
Declaration
protected void OnGet(RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
OnGet(RouteMatcher, SyncRouteHandlerCallback)
Associates GET
requests matching a route to a synchronous handler.
Declaration
protected void OnGet(RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
OnHead(RouteMatcher, RouteHandlerCallback)
Associates HEAD
requests matching a route to a handler.
Declaration
protected void OnHead(RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
OnHead(RouteMatcher, SyncRouteHandlerCallback)
Associates HEAD
requests matching a route to a synchronous handler.
Declaration
protected void OnHead(RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
OnMethodNotAllowedAsync(IHttpContext)
Called when at least one route is matched for the requested URL path, but none of them is associated with the HTTP method of the request.
The default behavior is to send an empty 405 Method Not Allowed
response.
Declaration
protected virtual Task OnMethodNotAllowedAsync(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttp |
context | The context of the request being handled. |
Returns
Type | Description |
---|---|
Task | A |
OnOptions(RouteMatcher, RouteHandlerCallback)
Associates OPTIONS
requests matching a route to a handler.
Declaration
protected void OnOptions(RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
OnOptions(RouteMatcher, SyncRouteHandlerCallback)
Associates OPTIONS
requests matching a route to a synchronous handler.
Declaration
protected void OnOptions(RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
OnPatch(RouteMatcher, RouteHandlerCallback)
Associates PATCH
requests matching a route to a handler.
Declaration
protected void OnPatch(RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
OnPatch(RouteMatcher, SyncRouteHandlerCallback)
Associates PATCH
requests matching a route to a synchronous handler.
Declaration
protected void OnPatch(RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
OnPathNotFoundAsync(IHttpContext)
Called when no route is matched for the requested URL path.
The default behavior is to send an empty 404 Not Found
response.
Declaration
protected virtual Task OnPathNotFoundAsync(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttp |
context | The context of the request being handled. |
Returns
Type | Description |
---|---|
Task | A |
OnPost(RouteMatcher, RouteHandlerCallback)
Associates POST
requests matching a route to a handler.
Declaration
protected void OnPost(RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
OnPost(RouteMatcher, SyncRouteHandlerCallback)
Associates POST
requests matching a route to a synchronous handler.
Declaration
protected void OnPost(RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
OnPut(RouteMatcher, RouteHandlerCallback)
Associates PUT
requests matching a route to a handler.
Declaration
protected void OnPut(RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Route |
handler | A callback used to handle matching contexts. |
OnPut(RouteMatcher, SyncRouteHandlerCallback)
Associates PUT
requests matching a route to a synchronous handler.
Declaration
protected void OnPut(RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
Route |
matcher | The Route |
Sync |
handler | A callback used to handle matching contexts. |
OnRequestAsync(IHttpContext)
Called to handle a request from a client.
Declaration
protected override Task OnRequestAsync(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttp |
context | The context of the request being handled. |
Returns
Type | Description |
---|---|
Task | A |