mck

command module
v0.0.0-...-c45f0ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

mck

pipeline status coverage report Go Report Card Documentation

CLI tool for mocking up external dependency of micro services / containers. Mck creates stand alone servers / containers which are accessed over the network, the same way as in the reality.

The tool is provided the script of sequential steps which are then returned in the same sequence when the server is hit with HTTP request. Content of the step supports both string and file content (response can be loaded from external file)

Installation:
Mac OS
brew tap pgmtc/repo
brew install mck
Linux, Windows
Example:
  • create a file called mck.yml with the following contents
ignores:
  - /favicon.ico

steps:
- contenttype: text/plain
  statuscode: 200
  content: Plain text response

- contenttype: text/xml
  statuscode: 200
  content: <data><element1>value1</element1></data>

- contenttype: application/json
  statuscode: 200
  content: "{ \"data\": { \"element1\": \"value1\" } }"
  
- contenttype: text/plain
  statuscode: 500
  content: some internal server error - go whistle
  • From the same directory, run the following mck

  • Point your browser to http://localhost:8080/ and keep refreshing. Responses should be following the same order ad the script

Content from the files

If the desired content to return is too big or it is inconvenient to define it on one line, you can provide file name instead

- contenttype: application/json
  statuscode: 200
  content: some-file.json
Delaying response

If you for some reason need to delay response, simply add delayms attribute

- contenttype: text/plain
  statuscode: 200
  content: some response
  delayms: 200
Supported arguments
  -f string
        file path to screenplay yaml (default "mck.yaml")
  -p int
        server port to listen on (default 8080)
  -w    run forever (restart after last step)
To Do:
  • support of cookies
  • support of http headers
  • distinguish among paths (each of the path could have its own sequence)
  • provide control API - ways to control responses interactively during the runtime as opposed to being loaded when the tool starts
  • recorder - provide pass through proxy to a real service and allow to record the real responses and store them in a script

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL