Unosquare
    Show / Hide Table of Contents

    Class RoutingModuleBase

    Base class for modules that handle requests by resolving route / method pairs associated with handlers.

    Inheritance
    Object
    WebModuleBase
    RoutingModuleBase
    RoutingModule
    Implements
    IWebModuleImpl
    IWebModule
    Inherited Members
    WebModuleBase.Container
    WebModuleBase.IWebModuleImpl.SetContainer(IWebModuleContainer)
    WebModuleBase.BaseRoute
    WebModuleBase.OnUnhandledException
    WebModuleBase.OnHttpException
    WebModuleBase.LogSource
    WebModuleBase.Start(CancellationToken)
    WebModuleBase.MatchUrlPath(String)
    WebModuleBase.HandleRequestAsync(IHttpContext)
    WebModuleBase.OnStart(CancellationToken)
    WebModuleBase.SetContainer(IWebModuleContainer)
    Namespace: EmbedIO.Routing
    Syntax
    public abstract class RoutingModuleBase : WebModuleBase, IWebModuleImpl, IWebModule

    Constructors

    RoutingModuleBase(String)

    Initializes a new instance of the RoutingModuleBase class.

    Declaration
    protected RoutingModuleBase(string baseRoute)
    Parameters
    Type Name Description
    String baseRoute

    The base route served by this module.

    See Also
    BaseRoute

    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
    WebModuleBase.IsFinalHandler
    Remarks

    If this property is true, a HTTP context's SetHandled() method will be automatically called immediately after after the returned by HandleRequestAsync(IHttpContext) is completed. This will prevent the context from being passed further along to other modules.

    See Also
    IsHandled
    SetHandled()

    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
    HttpVerb verb

    A HttpVerb constant representing the HTTP method to associate with handler, or Any if handler can handle all HTTP methods.

    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    HttpVerb verb

    A HttpVerb constant representing the HTTP method to associate with handler, or Any if handler can handle all HTTP methods.

    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback handler

    A callback used to handle matching contexts.

    AddHandlersFrom(Object)

    Adds handlers, associating them with HTTP method / route pairs by means of RouteAttribute attributes.

    See AddFrom(Object) for further information.

    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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback 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
    IHttpContext context

    The context of the request being handled.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    OnOptions(RouteMatcher, RouteHandlerCallback)

    Associates OPTIONS requests matching a route to a handler.

    Declaration
    protected void OnOptions(RouteMatcher matcher, RouteHandlerCallback handler)
    Parameters
    Type Name Description
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback 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
    IHttpContext context

    The context of the request being handled.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    OnPost(RouteMatcher, RouteHandlerCallback)

    Associates POST requests matching a route to a handler.

    Declaration
    protected void OnPost(RouteMatcher matcher, RouteHandlerCallback handler)
    Parameters
    Type Name Description
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    RouteHandlerCallback 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
    RouteMatcher matcher

    The RouteMatcher used to match URL paths.

    SyncRouteHandlerCallback 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
    IHttpContext context

    The context of the request being handled.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    Overrides
    WebModuleBase.OnRequestAsync(IHttpContext)

    Implements

    IWebModuleImpl
    IWebModule

    See Also

    WebModuleBase

    Comments

    Back to top Copyright © 2017-2019 Unosquare