feat(ringo-flow): HTTP mock server for webhook scenarios#26
Merged
Conversation
davidborzek
added a commit
that referenced
this pull request
Jun 22, 2026
Addresses review of #26. - reset_sessions now awaits each mock server's serving task after signalling shutdown, so an explicit reused port is provably released before the next scenario rebinds it (no "address in use" race). Test added. - Note in docs/comments that the on(...) responder runs on a runtime worker (don't block it), an oversized body reads as empty, and an invalid response header collapses to an empty reply. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mock the webhook a telephony API calls and answer with the call actions
to perform.
- mock_server([#{port}]) with respond/on routes and request_count/
last_request/requests, polled via await_until.
- Static and Rhai-closure responders; responder errors are logged and
answered with a bare 500, not exposed over HTTP.
- Runs on the shared runtime; torn down at reset_sessions.
Includes json_response/text_response helpers, an example and docs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- regex("/calls/.*") as a path matcher for respond/on/request_count/...
- Any-method routes via "*" or by omitting the method argument.
- Precedence: exact path > regex, exact method > any; ties go to the
last registered route. Re-registering still replaces in place.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses review of #26. - reset_sessions now awaits each mock server's serving task after signalling shutdown, so an explicit reused port is provably released before the next scenario rebinds it (no "address in use" race). Test added. - Note in docs/comments that the on(...) responder runs on a runtime worker (don't block it), an oversized body reads as empty, and an invalid response header collapses to an empty reply. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5291939 to
86c45d7
Compare
This was referenced Jun 22, 2026
Merged
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A scriptable HTTP mock server for
ringo-flow, for testing webhook-driventelephony APIs: the system under test calls a webhook for a call and the
scenario answers with the actions to perform.
Details
mock_server([#{port}])— free port by default; runs on the shared tokioruntime, torn down at
reset_sessions(per-scenario/-file isolation), and theserving task is awaited so the port is released before the next bind.
respond(static) andon(Rhai-closure) responders. Match by exactpath or
regex("/calls/.*"), and by a method or any ("*"/ omit it).Precedence: exact path > regex, exact method > any; re-registering a route
replaces it in place (response staging).
request_count/last_request/requests, polled via theexisting
await_until— no second waiting mechanism.MockRequestexposesmethod/path/body/header/query/json.json_response(map or array) andtext_response.is never exposed over HTTP.
Testing
regex + any-method routing, error-not-leaked, explicit-port release on teardown.
cargo fmt --all --check,cargo clippy --all-targets, andcargo test -p ringo-flow -p ringo-corepass. Exampleexamples/webhook-mock.rhai, README and generated docs updated.🤖 Generated with Claude Code