Table of Contents

Class RouterExtensions

Namespace
IceRpc
Assembly
IceRpc.dll

Provides extension methods for Router.

public static class RouterExtensions
Inheritance
RouterExtensions
Inherited Members

Methods

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

router Router

The router being configured.

service IDispatcher

The target service of this route.

Returns

Router

The router being configured.

Type Parameters

TService

An 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.

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

router Router

The router being configured.

prefix string

The prefix of the route to the sub-router.

configure Action<Router>

A delegate that configures the new sub-router.

Returns

Router

The new sub-router.

Exceptions

FormatException

Thrown if prefix is 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

router Router

The 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

router Router

The router being configured.

feature TFeature

The value of the feature to set in all requests.

Returns

Router

The router being configured.

Type Parameters

TFeature

The type of the feature.