Class RouteVerbResolverCollection
Handles a HTTP request by matching it against a list of routes, possibly handling different HTTP methods via different handlers.
Inheritance
Inherited Members
Namespace: EmbedIO.Routing
Syntax
public sealed class RouteVerbResolverCollection : RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>
Methods
AddFrom(Object)
Adds handlers, associating them with HTTP method / route pairs by means of RouteAttribute attributes.
A compatible handler is a static or instance method that takes 2 parameters having the following types, in order:
The return type of a compatible handler may be either langword_csharp_void
or
A compatible handler, in order to be added to a RouteVerbResolverCollection, must have one or more RouteAttribute attributes. The same handler will be added once for each such attribute, either declared on the handler, or inherited (if the handler is a virtual method).
This method behaves according to the type of the target
parameter:
- if
target
is a, all public static methods of the type (either declared on the same type or inherited) that are compatible handlers will be added to the collection; - if
target
is an, all public static methods of each exported type of the assembly (either declared on the same type or inherited) that are compatible handlers will be added to the collection; - if
target
is areferring to a compatible handler, it will be added to the collection; - if
target
is a langword_csharp_delegate whoseMethod refers to a compatible handler, that method will be added to the collection; - if
target
is none of the above, all public instance methods of its type (either declared on the same type or inherited) that are compatible handlers will be bound totarget
and added to the collection.
Declaration
public int AddFrom(object target)
Parameters
Type | Name | Description |
---|---|---|
Object | target | Where to look for compatible handlers. See the Summary section for more information. |
Returns
Type | Description |
---|---|
Int32 | The number of handlers that were added to the collection. Note that methods with multiple RouteAttribute attributes will count as one for each attribute. |
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 override RouteVerbResolver CreateResolver(RouteMatcher matcher)
Parameters
Type | Name | Description |
---|---|---|
RouteMatcher | matcher | The RouteMatcherto match URL paths against. |
Returns
Type | Description |
---|---|
RouteVerbResolver | A newly-constructed instance of |
Overrides
OnResolverCalled(IHttpContext, RouteVerbResolver, 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 override void OnResolverCalled(IHttpContext context, RouteVerbResolver resolver, RouteResolutionResult result)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The context to handle. |
RouteVerbResolver | resolver | |
RouteResolutionResult | result | The result returned by |