Class RouterExtensions
- Namespace
- IceRpc
- Assembly
- IceRpc.dll
Provides extension methods for Router.
public static class RouterExtensions
- Inheritance
-
RouterExtensions
- Inherited Members
Methods
Map(Router, IDispatcher)
Registers a route to a service that uses the service's default path as the route path. If there is an existing route at the same path, it is replaced.
public static Router Map(this Router router, IDispatcher service)
Parameters
routerRouterThe router being configured.
serviceIDispatcherThe target service of this route.
Returns
- Router
The router being configured.
Exceptions
- InvalidOperationException
Thrown if DispatchAsync(IncomingRequest, CancellationToken) was already called on this router.
- ArgumentException
Thrown if the interface(s) implemented by
servicedo not have a DefaultServicePathAttribute attribute, or ifserviceimplements multiple interfaces with a DefaultServicePathAttribute attribute.
Map<TService>(Router, IDispatcher)
Registers a route to a service that uses the service's default path as the route path. If there is an existing route at the same path, it is replaced.
public static Router Map<TService>(this Router router, IDispatcher service) where TService : class
Parameters
routerRouterThe router being configured.
serviceIDispatcherThe target service of this route.
Returns
- Router
The router being configured.
Type Parameters
TServiceA service interface with the DefaultServicePathAttribute attribute. The path of the mapped service corresponds to the value of this attribute.
Exceptions
- InvalidOperationException
Thrown if DispatchAsync(IncomingRequest, CancellationToken) was already called on this router.
- ArgumentException
Thrown if
TServicedoes not have a DefaultServicePathAttribute attribute.
Route(Router, string, Action<Router>)
Creates a sub-router, configures this sub-router and mounts it (with
Mount(string, IDispatcher)) at the given prefix.
public static Router Route(this Router router, string prefix, Action<Router> configure)
Parameters
routerRouterThe router being configured.
prefixstringThe prefix of the route to the sub-router.
configureAction<Router>A delegate that configures the new sub-router.
Returns
- Router
The new sub-router.
Exceptions
- FormatException
Thrown if
prefixis not a valid path.
UseDispatchInformation(Router)
Adds a middleware that creates and inserts the IDispatchInformationFeature feature in all requests.
public static Router UseDispatchInformation(this Router router)
Parameters
routerRouterThe router being configured.
Returns
- Router
The router being configured.
UseFeature<TFeature>(Router, TFeature)
Adds a middleware that sets a feature in all requests.
public static Router UseFeature<TFeature>(this Router router, TFeature feature)
Parameters
routerRouterThe router being configured.
featureTFeatureThe value of the feature to set in all requests.
Returns
- Router
The router being configured.
Type Parameters
TFeatureThe type of the feature.