The web-echo service is an immutable JSON data recording service.
This service allows you to easily define on the fly JSON recorders which can be fed by remote services using either the dynamically generated webhook or the websockets URL you've provided. Then, at any time you can check/get what has been sent by the remote services.
The storage implementation is using a blockchain approach to ensure data integrity; when data has been sent to the service, it always provides back a receipt proof.
Use scala-cli to download and start a web-echo service on port 8080 with API documentation on http://127.0.0.1:8080/docs :
scala-cli --dep fr.janalyse::web-echo:2.1.0 -e 'webecho.Main.main(args)'
Quick test once the web-service is started and running on port 8080
ENDPOINT=http://127.0.0.1:8080/api/v2
# create a new recorder and get its ID
ID=$(curl -X POST $ENDPOINT/recorder -H 'accept: application/json' | jq -r .id)
# simulate some data sent by a remote service
curl -s "$ENDPOINT/recorder/$ID?name=joe&age=42" | jq
curl -s -X PUT $ENDPOINT/recorder/$ID -H 'accept: application/json' -d '{"name":"jane","age":24}' | jq
curl -s -X POST $ENDPOINT/recorder/$ID -H 'accept: application/json' -d '{"name":"john","age":12}' | jq
# then check the recorded content
curl -s "$ENDPOINT/recorder/$ID/records" | jqFirst, starts a simple websocket server that just send ticks :
scala-cli basic-wss-server.sc -- 8888
# OR
scala-cli https://raw.githubusercontent.com/dacr/web-echo/refs/heads/master/basic-wss-server.sc -- 8888Then
ENDPOINT=http://127.0.0.1:8080/api/v2
# create a new recorder and get its ID
ID=$(curl -X POST $ENDPOINT/recorder -H 'accept: application/json' | jq -r .id)
# then register the websocket server to the recorder
curl -s -X POST $ENDPOINT/recorder/$ID/websocket -H 'accept: application/json' -d '{
"uri": "ws://127.0.0.1:8888",
"expire": "60 seconds"
}'
# then check the recorded content
curl -s "$ENDPOINT/recorder/$ID/records?limit=10" | jq .data.tick| Environment variable | Description | default value |
|---|---|---|
| WEB_ECHO_LISTEN_IP | Listening network interface | "0.0.0.0" |
| WEB_ECHO_LISTEN_PORT | Listening port | 8080 |
| WEB_ECHO_PREFIX | Add a prefix to all defined routes | "" |
| WEB_ECHO_URL | How this service is known from outside | "http://127.0.0.1:8080" |
| WEB_ECHO_STORE_PATH | Where data are stored | "/tmp/web-echo-cache-data" |
| WEB_ECHO_WEBSOCKETS_DEFAULT_DURATION | Default duration for websockets connection | 15m |
| WEB_ECHO_WEBSOCKETS_MAX_DURATION | Maximum duration for websockets connection | 4h |
| WEB_ECHO_SHA_GOAL | Difficulty level for Proof of Work (0=off) | 0 |
