仓库为 source-visible 但非开源,使用前需先看 LICENSE(Enterprise 许可);本地开发需先安装并启动 Redis,否则无法使用 response bins;请求体默认上限 5 MiB,超出返回 413,需用 MOCKBIN_MAX_BODY_BYTES 调整;仅支持 gzip/deflate 压缩请求体,br、zstd 等会返回 415。
insomnia-mockbin
Kong活跃维护Insomnia 的 API Mock 后端服务,用来给接口快速生成可调用的模拟响应,方便在真实服务就绪前调试和测试客户端。
Insomnia Mockbin is the underlying backend for the API mocks capability of Insomnia. It is built and used by Kong, the author of the open-source Kong Gateway.
git clone https://github.com/Kong/mockbin.git ./mockbin
cd mockbin
cp .env.sample .env
npm install
npm start
# 或直接 docker compose upREADME 未说明 GPU 或显存要求;本地运行需要 Redis(未启动 Redis 时仍可启动,但无法存取 response bins),也可用 Docker Compose 运行。
Kong 出品的 API Mock 后端,为 Insomnia 提供模拟接口能力,可自建 HTTP mock 服务
Insomnia 的 API Mock 后端服务,用来给接口快速生成可调用的模拟响应,方便在真实服务就绪前调试和测试客户端。
核心能力
- 使用 HAR 格式定义和存储 mock 响应
- 支持 JSON、YAML、XML、HTML 多种输出格式
- 通过 X-Forwarded-* 头正确解析代理后的客户端 IP
- 用 X-HTTP-Method-Override 头或 _method 参数覆盖 HTTP 方法
- 可创建自定义 bin 收集和调试请求日志
容易踩的坑
- v2.0.2最新正式版2024-07-01 · 2024-07-01 11:04 UTC
What's Changed
- fix bug in middleware by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/177
Full Changelog: https://github.com/Kong/insomnia-mockbin/compare/v2.0.1...v2.0.2
- v2.0.12024-06-28 · 2024-06-28 14:46 UTC
查看更新说明
What's Changed
- update license by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/174
- default to one million second expiry by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/173
- Fix npm audit warnings by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/175
- bump 2.0.1 by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/176
Full Changelog: https://github.com/Kong/insomnia-mockbin/compare/v2.0.0...v2.0.1
- v2.0.02024-04-26 · 2024-04-26 15:10 UTC
查看更新说明
What's Changed
- Modify mockbin script to use env vars or custom npm config by @marcel-dias in https://github.com/Kong/insomnia-mockbin/pull/57
- chore(branding): update Mashape -> Kong by @nijikokun in https://github.com/Kong/insomnia-mockbin/pull/85
- Upgrade libs by @quilicicf in https://github.com/Kong/insomnia-mockbin/pull/86
- Upgrade Dockerfile to use node:16-alpine by @mheap in https://github.com/Kong/insomnia-mockbin/pull/106
- Add PUT endpoint to modify bin response by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/130
- Fix typo in JSON and JSONP samples by @gitname in https://github.com/Kong/insomnia-mockbin/pull/71
- Add endpoint to delete bin by @agent019 in https://github.com/Kong/insomnia-mockbin/pull/83
- modernize repo by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/131
- Revert "modernize repo" by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/132
- Refactored working with latest node by @JamesGouldSonos in https://github.com/Kong/insomnia-mockbin/pull/118
- add github action by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/142
- Fix forms by @quilicicf in https://github.com/Kong/insomnia-mockbin/pull/91
- Bump the npm_and_yarn group group with 6 updates by @dependabot in https://github.com/Kong/insomnia-mockbin/pull/141
- Auto complete headers by @hsingh23 in https://github.com/Kong/insomnia-mockbin/pull/54
- npm audit fix by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/144
- update to node 21 by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/147
- remove package publishing tools by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/150
- Use-biome by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/146
- Remove-unirest by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/151
- Stream line install and config docs by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/152
- Support pathing by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/153
- Rename-upsert by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/154
- Update-redis v3 -> v4 by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/155
- use auto generated docker release yaml by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/157
- (feat/SEC-1010): Add SAST scanning using semgrep by @saisatishkarra in https://github.com/Kong/insomnia-mockbin/pull/158
- update dot env by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/159
- add ttl setting by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/161
- chore: Get Docker Compose Working by @johnnyhuy in https://github.com/Kong/insomnia-mockbin/pull/160
- harden dockerfile by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/165
- skip healthcheck by @jackkav in https://github.com/Kong/insomnia-mockbin/pull/168
- ci(.github)[SEC-1084]: SLSA supply chain security controls by @saisatishkarra in https://github.com/Kong/insomnia-mockbin/pull/170
- ci(.github)[SEC-1084]: fix image digest for provenance by @saisatishkarra in https://github.com/Kong/insomnia-mockbin/pull/171
- Fix workflow permissions for publishing security assets to releases by @saisatishkarra in https://github.com/Kong/insomnia-mockbin/pull/172
New Contributors
- @marcel-dias made their first contribution in https://github.com/Kong/insomnia-mockbin/pull/57
- @nijikokun made their first contribution in https://github.com/Kong/insomnia-mockbin/pull/85
- @quilicicf made their first contribution in https://github.com/Kong/insomnia-mockbin/pull/86
- @mheap made their first contribution in https://github.com/Kong/insomnia-mockbin/pull/106
- @jackkav made their first contribution in https://github.com/Kong/insomnia-mockbin/pull/130
- @gitname made their first contribution in https://github.com/Kong/insomnia-mockbin/pull/71
- @agent019 made their first contribution in https://github.com/Kong/insomnia-mockbin/pull/83
- @JamesGouldSonos made the
- v1.6.32016-02-12 · 2016-02-12 04:40 UTC
查看更新说明
<a name"1.6.3">
1.6.3 (2016-02-12)
Bug Fixes
- bins: update har-validator to promise version (cb362b58)
- v1.6.22016-02-12 · 2016-02-12 04:05 UTC
查看更新说明
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Insomnia Mockbin

Note: This repository is source visibile, but not open-source. Please check the LICENSE before using this software.
Insomnia Mockbin is maintained by Kong, who also maintains the open-source API Gateway Kong and Insomnia.
Table of contents
Features
- uses HAR format
- supports JSON, YAML, XML, HTML output
- plays nice with proxies (uses the
X-Forwarded-*headers for IP resolution) - allows for HTTP Method Override using the header
X-HTTP-Method-Overrideor through query string parameter:_method - create custom bins for experimenting log collection
Local Development
Requirements
brew install redis
brew services start redis
Redis should be now running on localhost:6379 Mockbin will start without redis but you wont be able to set or get response bins.
git clone https://github.com/Kong/mockbin.git ./mockbin
cd mockbin
cp .env.sample .env
brew install fnm
fnm use
npm install
Note: nvm, n or volta can be used instead of fnm.
Running with Node
npm start
# OR watch for changes
npm run dev
# OR with debug logs
DEBUG=mockbin npm run dev
Running with Docker Compose
docker compose up
Releasing
Run the following command and push the newly created commit into your PR. This will bump commit and tag, you will need to push this to the remote, which trigger the release action upon merging the PR.
npm version patch
git push origin tag <tag_name>
Documentation
API Docs
Read the full API documentation, please review the API Docs.
Request body size limit and compression
Mockbin reads each request body into memory, so a request with a body larger than the limit is refused with 413 Payload Too Large. The default limit is 5 MiB (5242880 bytes), sized for the cloud-hosted mock service. Earlier versions did not limit the request body.
A request body compressed with Content-Encoding: gzip or deflate is decompressed before it is parsed, so the limit applies to the decompressed size, and templates can read its fields. Any other Content-Encoding (for example br or zstd) is refused with 415, and a body that is not valid compressed data with 400. Earlier versions did not decompress request bodies and accepted any Content-Encoding.
If you host Mockbin yourself and need larger bodies, set MOCKBIN_MAX_BODY_BYTES to the limit in bytes. 0 removes the limit, including the limit on the decompressed size.
# accept request bodies up to 20 MiB
MOCKBIN_MAX_BODY_BYTES=20971520
The response body of a mock (content.text) has its own, fixed limit: 1,000,000 characters, the longest body Mockbin can serve.
Deployment
See https://developer.konghq.com/insomnia/mock-servers/ for the available options for deploying mockbin.
Software Bill of materials
Kong Insomnia Mockbin produces SBOMs for the below categories:
- For docker container images
- For source code repository
The SBOMs are available to download at:
- Github Release / Tag Assets
- Github workflow assets for other workflow runs
Verify a container image signature
Docker container images are now signed using cosign with signatures published to a Github Container registry with insomnia-mockbin repository. Separate images are published for cloud hosted mocks (ghcr.io/kong/insomnia-mockbin-cloud) and self-hosted mocks (ghcr.io/kong/insomnia-mockbin-self-hosted). Modify the examples below if you need to verify the image for self-hosted mocks.
Steps to verify signatures for signed Kong Insomnia Mockbin Docker container images in two different ways:
A minimal example, used to verify an image without leveraging any annotations. For the minimal example, you only need Docker details, a GitHub repo name, and a GitHub workflow filename.
cosign verify \
ghcr.io/kong/insomnia-mockbin-cloud:<tag>@sha256:<digest> \
--certificate-oidc-issuer='https://token.actions.githubusercontent.com' \
--certificate-identity-regexp='https://github.com/Kong/insomnia-mockbin/.github/workflows/release.yaml'
A complete example, leveraging optional annotations for increased trust. For the complete example, you need the same details as the minimal example, as well as any of the optional annotations you wish to verify:
cosign verify \
ghcr.io/kong/insomnia-mockbin-cloud:<tag>@sha256:<digest> \
--certificate-oidc-issuer='https://token.actions.githubusercontent.com' \
--certificate-identity-regexp='https://github.com/Kong/insomnia-mockbin/.github/workflows/release.yaml' \
-a repo='Kong/insomnia-mockbin' \
-a workflow='Package & Release'
Verify a container image provenance
Kong Insomnia Mockbin produces build provenance for docker container images for Github tags, which can be verified using cosign / slsa-verifier with attestations published to a Github Container registry with insomnia-mockbin repository.
Steps to verify provenance for signed Kong Insomnia Mockbin Docker container images:
-
Fetch the image
<manifest_digest>using regctl:regctl image digest ghcr.io/kong/insomnia-mockbin-cloud:<tag> -
A minimal example, used to verify an image without leveraging any annotations. For the minimal example, you only need Docker Image manifest, a GitHub repo name.
cosign verify-attestation \ ghcr.io/kong/insomnia-mockbin-cloud:<tag>@sha256:<manifest_digest> \ --type='slsaprovenance' \ --certificate-oidc-issuer='https://token.actions.githubusercontent.com' \ --certificate-identity-regexp='^https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/tags/v[0-9]+.[0-9]+.[0-9]+$'slsa-verifier verify-image \ ghcr.io/kong/insomnia-mockbin-cloud:<tag>@sha256:<manifest_digest> \ --print-provenance \ --source-uri 'github.com/Kong/insomnia-mockbin' -
A complete example, leveraging optional annotations for increased trust. For the complete example, you need the same details as the minimal example, as well as any of the optional annotations you wish to verify:
cosign verify-attestation \ ghcr.io/kong/insomnia-mockbin-cloud:<tag>@sha256:<manifest_digest> \ --type='slsaprovenance' \ --certificate-oidc-issuer='https://token.actions.githubusercontent.com' \ --certificate-identity-regexp='^https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/tags/v[0-9]+.[0-9]+.[0-9]+$' \ --certificate-github-workflow-repository='Kong/insomnia-mockbin' \ --certificate-github-workflow-name='Package & Release'slsa-verifier verify-image \ ghcr.io/kong/insomnia-mockbin-cloud:<tag>@sha256:<manifest_digest> \ --print-provenance \ --source-uri 'github.com/Kong/insomnia-mockbin' \ --source-tag '<tag>'
Bugs and feature requests
Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.
Contributing
Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.
More over, if your pull request contains JavaScript patches or features, you must include relevant unit tests.
Editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at http://editorconfig.org.