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.
Namespace
Google.Api.Gax.GrpcAssembly
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. |
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 | Func<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 | |
---|---|
Type | Description |
RoutingHeaderExtractor<TRequest> |