Class RoutingHeaderExtractor<TRequest> (4.2.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

NameDescription
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
NameDescription
requestTRequest

A request to extract the routing header parameters and values from

Returns
TypeDescription
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
NameDescription
valueObject

The value to format. May be null.

Returns
TypeDescription
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
NameDescription
paramNameString

The name of the parameter in the routing header.

extractionRegexString

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

selectorFunc<TRequest, String>

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
TypeDescription
RoutingHeaderExtractor<TRequest>