pathFilter is the everyday selector for URL paths in a Fluxzy rule. It supports literal, prefix, suffix, contains and regex matching, and it considers the query string when one is present. Pair it with hostFilter to scope to a specific endpoint on a specific host, and combine it with any of the actions below to mock, throttle or tag the matched traffic.
Reach for pathFilter when you want to scope a rule by the URL path of the request. It is the most common selector in real rule files, because most application logic is tied to specific routes.
Typical situations:
/api/ regardless of the verb or content type./users/me with an exact comparison./users/{id}/orders.The filter evaluates on the requestHeaderReceivedFromClient scope, so the path is available as soon as the request line is parsed. The path includes the query string when one is present and must start with /. Use absoluteUriFilter when you need to match the host or scheme as well.
Return a canned response for any call to the legacy v1 API while leaving v2 untouched. Useful during a migration when you want clients to fail fast on the deprecated routes.
rules:
- filter:
typeKind: PathFilter
pattern: /api/v1/
operation: StartsWith
actions:
- typeKind: MockedResponseAction
response:
statusCode: 410
body:
type: fromString
text: "v1 has been retired"
contentType: text/plain
Slow down requests targeting the search route to reproduce a latency issue without affecting the rest of the application.
rules:
- filter:
typeKind: PathFilter
pattern: /search
operation: Exact
actions:
- typeKind: AverageThrottleAction
bandwidthBytesPerSeconds: 65536
Apply a tag to every call under /users//orders, where the id is variable, by using a regex on the path.
rules:
- filter:
typeKind: PathFilter
pattern: ^/users/[^/]+/orders$
operation: Regex
actions:
- typeKind: ApplyTagAction
tag:
value: user-orders
Select exchanges according to url path. Path includes query string if any. Path must start with /
Evaluation scope defines the timing where this filter will be applied.
requestHeaderReceivedFromClient This scope occurs the moment fluxzy parsed the request header receiveid from client
pathFilter
The following table describes the customizable properties available for this filter:
| Property | Type | Description | DefaultValue |
|---|---|---|---|
| pattern | string | The string pattern to search | |
| operation | exact | contains | startsWith | endsWith | regex | The search operation performed | contains |
| caseSensitive | boolean | true if the Search should be case sensitive | false |
| inverted | boolean | Negate the filter result | false |
The following examples apply a comment to the filtered exchange
Retains only exchanges having uri starting with API.
rules:
- filter:
typeKind: PathFilter
pattern: /api
operation: StartsWith
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
View definition of PathFilter for .NET integration.
The following filters are related to this filter:
Yes. The path Fluxzy compares against includes the query string when one is present. Use a regex if your match should ignore the query, for example ^/foo(?.*)?$.
No by default. Paths are normalized to lowercase before comparison unless you set caseSensitive to true. URL paths are technically case sensitive on the wire, so flip the flag when correctness matters.
pathFilter only inspects the path (and query). absoluteUriFilter inspects the full URI including scheme and host. Prefer pathFilter when the host is implied by a separate hostFilter, it is faster and easier to read.
Yes, the Regex operation accepts any .NET regular expression. Captures are not exposed as variables, but you can still match complex shapes such as /users/[0-9]+/profile.