Smocker 是一个简单高效的 HTTP 模拟服务器和代理
Smocker (server mock) 是一个简单高效的 HTTP 模拟服务器。文档可在 smocker.dev 上查看。
# This will be the deployment folder for the Smocker instance
mkdir -p /opt/smocker && cd /opt/smocker
wget -P /tmp https://github.com/smocker-dev/smocker/releases/latest/download/smocker.tar.gz
tar xf /tmp/smocker.tar.gz
nohup ./smocker -mock-server-listen-port=8080 -config-listen-port=8081 &curl localhost:8081/versionSmocker 提供了一个配置用户界面。您可以在 http://localhost:8081/. 上的 Web 浏览器中访问此界面。
Smocker 具有两个端口:
8080 是模拟服务器端口。它将暴露您通过配置端口注册的路由8081 是配置端口。这是您用于注册新模拟的端口。此端口还提供了用户界面。要注册模拟对象,您可以使用 YAML 和 JSON 格式。一个基本的模拟对象可能看起来如下:
# helloworld.yml
# This mock register two routes: GET /hello/world and GET /foo/bar
- request:
# Note: the method could be omitted because GET is the default
method: GET
path: /hello/world
response:
# Note: the status could be omitted because 200 is the default
status: 200
headers:
Content-Type: application/json
body: >
{
"hello": "Hello, World!"
}
- request:
method: GET
path: /foo/bar
response:
status: 204暂无开放 Issues,或尚未同步最近议题。