Skip to main content

Module mocking

Module mocking 

Source
Expand description

Mocking plugin (mocking) — a faithful subset of Apache APISIX’s mocking plugin: responds with a configured mock instead of proxying upstream. Useful for stubbing APIs during development and testing.

Terminal wiring: a mocking node always answers the request itself, so it returns Ok with the mock written onto Context.response — wire its success port straight to client.in (never to an upstream). The error port is never taken.

Deviation from APISIX: response_schema (random body generation from a JSON schema) is not implemented — configs that set it are rejected at load, so response_example is required.

Structs§

MockingPlugin
Builds a mock response: optional delay, then status + headers + body. The body and string header values support $var interpolation.

Constants§

SUPPORTED_CONTENT_TYPES 🔒
Content types the plugin accepts (matched on the part before ;), mirroring APISIX’s support_content_type.

Functions§

parse_headers 🔒
Accepts response_headers as a map ({name: value}) or as the UI editor’s array form ([{name, value}]); scalar values are stringified, other shapes are rejected. Header names are lowercased.