2个不稳定版本
0.2.0 | 2023年6月29日 |
---|---|
0.1.0 | 2023年6月9日 |
#1280 in HTTP服务器
30KB
285 代码行
echo-rs
echo-rs
提供了一个极其简单的HTTP回声服务器 - 即,它以开发者友好的JSON序列化格式简单地将接收到的任何请求回显回来。
它的目标是提供简单便捷的工具,以辅助设计新应用程序,开发/测试API客户端,或作为“虚拟”工作负载用于构建新的Kubernetes/云原生服务。
许可证
特性
echo-rs
提供
- 一个简单的HTTP回声服务器,返回任何对它发出的请求的JSON序列化表示
- Prometheus度量(在为新Kubernetes服务设计时,当使用
echo-rs
作为虚拟工作负载时很有帮助)
基本用法
本地运行服务器 -
docker run -it -p 8080:8080 --rm docker.io/thewondersmith/echo-rs:latest --metrics=false --log-level=debug
然后用任何HTTP客户端向它发送请求 -
curl -X POST \
"https://127.0.0.1:8080/some/super-cool/endpoint?param1=some-param-value¶m2=another-param-value" \
-H 'Content-Type: application/json' \
-H 'App-Specific-Header: app_specific_value' \
-d '{"target": "echo-rs", "expected": "response", "some": ["more", "none", null], "nested": {"turtles": {"all": {"the": {"way": "down"}}}}}'
echo-rs
应该返回请求的JSON序列化表示 -
{
"method": "POST",
"path": "/some/super-cool/endpoint",
"headers": {
"user-agent": "curl/7.87.0",
"host": "localhost:8080",
"accept": "*/*",
"content-type": "application/json",
"app-specific-header": "app_specific_value",
"content-length": "135"
},
"params": {
"param1": "some-param-value",
"param2": "another-param-value"
},
"body": {
"expected": "response",
"nested": {
"turtles": {
"all": {
"the": {
"way": "down"
}
}
}
},
"some": [
"more",
"none",
null
],
"target": "echo-rs"
}
}
待办事项
- 测试 😅
依赖项
~23–39MB
~664K SLoC