docker run --rm --init -p 3000:3000 -e RUST_LOG=debug sstc/echo-server
All system api are prefix with
/_/
curl localhost:3000/_/version # Server version
curl localhost:3000/_/foo # Unknown api would response 404
It would echo request body if request without prefix of system api (works with all http verbs, except OPTIONS and HEAD).
curl -v localhost:3000/foo -d '{"a":123}'
...
* Connection #0 to host localhost left intact
{"a":123}
It would response the requested status by the header x-echo-status.
curl -v localhost:3000/foo -H "x-echo-status: 400"
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /foo HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.81.0
> Accept: */*
> x-echo-status: 400
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< content-length: 0
< date: Wed, 09 Feb 2022 21:05:23 GMT
<
* Connection #0 to host localhost left intact
It would response 400 and x-echo-status-error if header x-echo-status is invalid.
curl -v localhost:3000/foo -H "x-echo-status: bar"
...
> x-echo-status: bar
...
...
< HTTP/1.1 400 Bad Request
< x-echo-status-error: invalid digit found in string
...
It would response content-type if request path with extension name.
curl -v localhost:3000/foo.json -d '{"a":123}'
...
< content-type: application/json
...
The OPTIONS (preflight) handle CORS (won't echo).
curl -v localhost:3000/foo \
-XOPTIONS \
-H "Origin: http://foo.bar" \
-H "Access-Control-Request-Method: FOOMETHOD" \
-H "Access-Control-Request-Headers: BAR"
* Connected to localhost (127.0.0.1) port 3000 (#0)
> OPTIONS /foo HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.81.0
> Accept: */*
> Origin: http://foo.bar
> Access-Control-Request-Method: FOOMETHOD
> Access-Control-Request-Headers: BAR
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< access-control-allow-origin: http://foo.bar
< access-control-allow-methods: FOOMETHOD
< access-control-allow-headers: BAR
< content-length: 0
< date: Wed, 09 Feb 2022 21:02:17 GMT
<
* Connection #0 to host localhost left intact
The HEAD (body-less) would response with empty body (won't echo).
curl -v localhost:3000/foo \
-XHEAD \
-d '{"a":123}'
* Connected to localhost (127.0.0.1) port 3000 (#0)
> HEAD /foo HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Length: 9
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 9 out of 9 bytes
< HTTP/1.1 200 OK
< content-length: 0
< date: Sat, 16 Feb 2019 08:20:28 GMT
<
* Connection #0 to host localhost left intact
RUST_LOG="debug" cargo watch -x run -w src
Bump version
cargo bump patchThe chinese translation of this app is "複讀機" (meme)
Why? It's human nature.
因為這是人類本質。
Content type
Image
Digest
sha256:d8d8f705b…
Size
1.3 MB
Last updated
about 2 years ago
docker pull sstc/echo-server