Class RoutingHeaderExtractor<TRequest> (4.4.0)

public sealed class RoutingHeaderExtractor<TRequest>

Collects the explicit routing header extraction instructions and extracts the routing header value from a specific request using these instructions. This class is immutable.

Inheritance

object > RoutingHeaderExtractor<TRequest>

Namespace

Google.Api.Gax.Grpc

Assembly

Google.Api.Gax.Grpc.dll

Type Parameter

Name Description
TRequest

Constructors

RoutingHeaderExtractor()

public RoutingHeaderExtractor()

Create a new RoutingHeaderExtractor with no patterns. (This cannot be used to extract headers; new instances must be created with WithExtractedParameter(string, string, Func<TRequest, string>) which provides patterns to use to extract values.)

Methods

ExtractHeader(TRequest)

public string ExtractHeader(TRequest request)

Extracts the routing header value to apply based on a request.

Parameter
Name Description
request TRequest

A request to extract the routing header parameters and values from

Returns
Type Description
string

The value to use for the routing header. This may contain multiple &-separated parameters.

FormatRoutingHeaderValue(object)

public static string FormatRoutingHeaderValue(object value)

Returns a string representation of the given value, suitable for including in a routing header. (This method does not perform URI encoding; it is expected that the result of this method will either be used in WithExtractedParameter(string, string, Func<TRequest, string>), or as an argument to WithGoogleRequestParam(string, Func<TRequest, string>).)

Parameter
Name Description
value object

The value to format. May be null.

Returns
Type Description
string

The formatted value, or null if value is null.

WithExtractedParameter(string, string, Func<TRequest, string>)

public RoutingHeaderExtractor<TRequest> WithExtractedParameter(string paramName, string extractionRegex, Func<TRequest, string> selector)

Returns a new instance with the same parameter extractors as this one, with an additional one specified as arguments. The extractions follow the "last successfully matched wins" rule for conflict resolution when there are multiple extractions for the same parameter name. (See google/api/routing.proto for further details.) If multiple parameters with different names are present, the extracted header will contain them in the order in which they have been added with this method, based on the first occurrence of each parameter name.

Parameters
Name Description
paramName string

The name of the parameter in the routing header.

extractionRegex string

The regular expression (in string form) used to extract the value of the parameter. Must have exactly one capturing group (in addition to the implicit "group 0" which captures the whole match).

selector Funcstring

A function to call on each request, to determine the string to extract the header value from. The parameter must not be null, but may return null.

Returns
Type Description
RoutingHeaderExtractor