Skip to content

RouteMatcher class

Defined in

Namespace: Refit.Testing Assembly: Refit.Testing.dll Full name: Refit.Testing.RouteMatcher Modifiers: public sealed

Summary

View source

Matches an incoming request by HTTP method and a path Template that mirrors the [Get("/users/{id}")] attributes on a Refit interface. Build the common cases with the Route factory; set the optional properties directly for finer matching.

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481, net471

Remarks

The template is matched a segment at a time: a {name} segment matches any single non-empty path segment, and every other segment must match literally. A relative template ("/users/1") matches the request's absolute path; an absolute template ("https://api/users/1") matches the whole scheme/host/path. Use "*" to match any path. The query string is matched by Query, not the template.

Constructors

NameSummary
.ctor

Properties

NameSummary
MethodGets the HTTP method to match; null matches any method.
TemplateGets the path template to match (relative or absolute; {name} matches one segment; "*" matches any path).
QueryGets query key/value pairs the request must contain (a partial match; other params allowed).
ExactQueryGets the exact raw query string (without the leading ?) the request must have.
ExactQueryParamsGets the complete, decoded set of query pairs the request must have (no extras, order-insensitive).
HeadersGets header name/value pairs the request must contain (request or content headers).
BodyGets the exact request body the request must carry.
FormDataGets form-encoded key/value pairs the request body must contain (a partial match).
WhereGets an arbitrary predicate the request must satisfy.
WhereAsyncGets an asynchronous predicate the request must satisfy, for matchers that await (e.g. reading the request body).
ReusableGets a value indicating whether this route may match repeatedly and is not required by [VerifyAllCalled](#
Inherited members