Class RouteResolverCollectionBase<TData, TResolver>
Implements the logic for resolving a context and a URL path against a list of routes, possibly handling different HTTP methods via different handlers.
Namespace: EmbedIO.Routing
Syntax
public abstract class RouteResolverCollectionBase<TData, TResolver> : ConfiguredObject where TResolver : RouteResolverBase<TData>
Type Parameters
Name | Description |
---|---|
TData | The type of the data used to select a suitable handler for a context. |
TResolver | The type of the route resolver. |
Methods
Add(TData, RouteMatcher, RouteHandlerCallback)
Associates some data and a route to a handler.
Declaration
public void Add(TData data, RouteMatcher matcher, RouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
TData | data | Data used to determine which contexts are
suitable to be handled by |
RouteMatcher | matcher | The RouteMatcherto match URL paths against. |
RouteHandlerCallback | handler | A callback used to handle matching contexts. |
See Also
Add(TData, RouteMatcher, SyncRouteHandlerCallback)
Associates some data and a route to a synchronous handler.
Declaration
public void Add(TData data, RouteMatcher matcher, SyncRouteHandlerCallback handler)
Parameters
Type | Name | Description |
---|---|---|
TData | data | Data used to determine which contexts are
suitable to be handled by |
RouteMatcher | matcher | The RouteMatcherto match URL paths against. |
SyncRouteHandlerCallback | handler | A callback used to handle matching contexts. |
See Also
CreateResolver(RouteMatcher)
Called by Add(TData, RouteMatcher, RouteHandlerCallback)
and Add(TData, RouteMatcher, SyncRouteHandlerCallback) to create an instance
of TResolver
that can resolve the specified route.
If this method returns null, an
Declaration
protected abstract TResolver CreateResolver(RouteMatcher matcher)
Parameters
Type | Name | Description |
---|---|---|
RouteMatcher | matcher | The RouteMatcherto match URL paths against. |
Returns
Type | Description |
---|---|
TResolver | A newly-constructed instance of |
Lock()
Locks this collection, preventing further additions.
Declaration
public void Lock()
OnBeforeLockConfiguration()
Declaration
protected override void OnBeforeLockConfiguration()
OnResolverCalled(IHttpContext, TResolver, RouteResolutionResult)
Called by ResolveAsync(IHttpContext) when a resolver's ResolveAsync(IHttpContext) method has been called to resolve a context.
This callback method may be used e.g. for logging or testing.
Declaration
protected virtual void OnResolverCalled(IHttpContext context, TResolver resolver, RouteResolutionResult result)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The context to handle. |
TResolver | resolver | The resolver just called. |
RouteResolutionResult | result | The result returned by |
ResolveAsync(IHttpContext)
Asynchronously matches a URL path against Route;
if the match is successful, tries to handle the specified context
using handlers selected according to data extracted from the context.
Registered resolvers are tried in the same order they were added by calling
Declaration
public Task<RouteResolutionResult> ResolveAsync(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The context to handle. |
Returns
Type | Description |
---|---|
Task<RouteResolutionResult> | A |