项目作者: agukrapo

项目描述 :
A minimalistic mock server
高级语言: Go
项目地址: git://github.com/agukrapo/simpler-mock-server.git
创建时间: 2021-06-24T21:43:56Z
项目社区:https://github.com/agukrapo/simpler-mock-server

开源协议:

下载


simpler-mock-server

SMS is a minimalistic mock http server that uses a filesystem as backend.

Usage

  1. go install github.com/agukrapo/simpler-mock-server/cmd/sms@latest
  2. mkdir .sms_responses
  3. sms

To add a new route drop a file into the responses dir (default: ./.sms_responses) subfolder that matches the route HTTP method

Example

Executing

  1. echo "world!" > .sms_responses/GET/hello.txt

will create a new /hello route we can call with

  1. curl localhost:4321/hello

Default response status

Method status
DELETE 202
GET 200
PATCH 204
POST 201
PUT 204

Can be customized adding a prefix {status}___ to the file:

  1. .sms_responses/PATCH/api/people/500___a3b69b44-d562-11eb-b8bc-0242ac130003.json

Environment Variables

  • PORT (default: 4321)
  • ADDRESS (default: :$PORT)
  • LOG_LEVEL (default: debug)
  • RESPONSES_DIR - Directory where the response files are located (default: ./.sms_responses)
  • EXTENSION_MIME_TYPE_MAP - File extension to http request Accept MIME type, e.g. txt:text/plain
  • METHOD_STATUS_MAP - Request http method to response http status (default: DELETE:202,GET:200,PATCH:204,POST:201,PUT:204)

TODO

  • Better README