百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

smocker

> 前端框架
开源

Smocker 是一个简单高效的 HTTP 模拟服务器和代理

1.3K stars0 点赞2 次浏览
访问官网GitHub

工具介绍

Smocker 是一个简单高效的 HTTP 模拟服务器和代理

Smocker (server mock) 是一个简单高效的 HTTP 模拟服务器。文档可在 smocker.dev 上查看。

bash
# 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 &

健康检查

bash
curl localhost:8081/version

用户界面

Smocker 提供了一个配置用户界面。您可以在 http://localhost:8081/. 上的 Web 浏览器中访问此界面。

使用方法

Smocker 具有两个端口:

  • 8080 是模拟服务器端口。它将暴露您通过配置端口注册的路由
  • 8081 是配置端口。这是您用于注册新模拟的端口。此端口还提供了用户界面。

你好, 世界!

要注册模拟对象,您可以使用 YAML 和 JSON 格式。一个基本的模拟对象可能看起来如下:

yaml
# 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· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptapifunctional-testinggointegration-testing

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架