New Fluxzy v2 just shipped. Electron is out, Tauri is in. gRPC ready, 3x smaller install. Learn more

serveDirectoryAction Action

Reply to matching requests with files from a local directory so Fluxzy acts as a lightweight static web server for mocking and offline testing.

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.

When to use this action

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:

  • Mock a third party site so integration tests run offline.
  • Demo a website without depending on a live deployment.
  • Replace a flaky CDN with a snapshot of its assets during a debugging session.

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.

Real world examples

Mock a partner API host with snapshot responses

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

Replace a third party CDN with local assets

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

Serve a legacy site from disk while the new one is rebuilt

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

Reference

serveDirectoryAction

Description

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

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

serveDirectoryAction

Settings

The following table describes the customizable properties available for this action:

Property Type Description DefaultValue
directory string Directory to serve

Example of usage

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

.NET reference

View definition of ServeDirectoryAction for .NET integration.

See also

The following actions are related to this action:

Frequently asked questions

Is this safe for production traffic?

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.

How does Fluxzy decide which file to serve?

The request path is appended to the directory you configured. If the resulting file exists, it is served. Otherwise the client receives a 404.

What content type is used?

Fluxzy infers the content type from the file extension. If you need a specific value, switch to mockedResponseAction where you can set headers explicitly.

Can I serve different directories for different paths on the same host?

Yes. Define several rules with path filters so each path prefix maps to its own directory on disk.

Learn more about Fluxzy rules