When a real upstream gets in the way of reproducible testing, the simplest fix is to replace it with a folder full of files. serveDirectoryAction makes that swap trivial: point at a directory, scope the filter to the right host, and Fluxzy answers as if the real service were online.
serveDirectoryAction turns Fluxzy into a small static web server for mocked content. Use it when you need a host to respond with deterministic files rather than reaching a real upstream.
Good fits:
The action picks the file matching the request path and serves it with a sensible content type based on the file extension. It is intentionally not a production web server.
Stash a directory tree of canned responses on disk and have Fluxzy serve them whenever the partner host is requested. Tests become reproducible and offline friendly.
rules:
- filter:
typeKind: HostFilter
pattern: api.partner.example.com
actions:
- typeKind: ServeDirectoryAction
directory: /var/fluxzy/mocks/partner-api
Useful for offline demos. The directory mirrors the path layout of the CDN so existing requests resolve without any client side change.
rules:
- filter:
typeKind: HostFilter
pattern: cdn.example.com
actions:
- typeKind: ServeDirectoryAction
directory: /home/dev/snapshots/cdn-mirror
Pin the existing site as a snapshot so teammates can keep working against a stable version while you migrate the real backend.
rules:
- filter:
typeKind: HostFilter
pattern: legacy.example.com
actions:
- typeKind: ServeDirectoryAction
directory: /opt/snapshots/legacy-site
Serve a folder as a static web site. This action is made for mocking purpose and not production ready for a web site.
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
serveDirectoryAction
The following table describes the customizable properties available for this action:
| Property | Type | Description | DefaultValue |
|---|---|---|---|
| directory | string | Directory to serve |
The following examples apply this action to any exchanges
Serve a directory.
rules:
- filter:
typeKind: AnyFilter
actions:
- typeKind: ServeDirectoryAction
directory: /path/to/my/static/website
View definition of ServeDirectoryAction for .NET integration.
The following actions are related to this action:
No. The action is built for mocking. It has no access control, no streaming optimisations, and no production grade error handling. Use a real web server for production deployments.
The request path is appended to the directory you configured. If the resulting file exists, it is served. Otherwise the client receives a 404.
Fluxzy infers the content type from the file extension. If you need a specific value, switch to mockedResponseAction where you can set headers explicitly.
Yes. Define several rules with path filters so each path prefix maps to its own directory on disk.