New Transparent capture is in preview. Record every app's traffic with no proxy configuration, on Windows, macOS and Linux. Learn more

pathFilter Filter

Select exchanges by the URL path (including query string), with exact, prefix, suffix, contains or regex matching.

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.

When to use this filter

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:

  • Targeting every call under /api/ regardless of the verb or content type.
  • Matching a specific endpoint such as /users/me with an exact comparison.
  • Selecting paths by regex when the route contains a variable segment, for example /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.

Real world examples

Mock every call under /api/v1

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

Throttle the search endpoint

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

Tag user detail calls with a regex

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

Reference

pathFilter

Description

Select exchanges according to url path. Path includes query string if any. Path must start with /

Evaluation scope

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

YAML configuration name

pathFilter

Settings

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

Example of usage

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

.NET reference

View definition of PathFilter for .NET integration.

See also

The following filters are related to this filter:

Frequently asked questions

Does pathFilter include the query string?

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(?.*)?$.

Is the comparison case sensitive?

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.

How does pathFilter differ from absoluteUriFilter?

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.

Can I match a regex with a captured group?

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.

Learn more about Fluxzy rules