api-mock

command module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 6 Imported by: 0

README

API Mocker

Simple API mock that will help to serve JSON response that's been defined in config (yaml) file

How to Use

  1. Download the binary from GitHub Releases
  2. Extract to dir api-mock/
    mkdir api-mock
    tar -C api-mock -xzf api-mock_version_os_arch.tar.gz
    
  3. Create app config file.
    cp app.yml.example app.yml
    
    Above app config will read json response in current directory with response.yml as the config filename.
  4. Create yaml file to define the endpoint along with their respective response
    cp response.yml.example response.yml
    
  5. Run
    ./api-mock
    
  6. Hit endpoint /api/v1/test will return status code 200 and json response like
    {
      "messages": "data was found",
      "data": {
        "status": "okay",
        "detail": true
      },
      "errors": null,
      "code": 200
    }
    
  7. You can add another endpoint along with their json response as many as you want, and of course you does not need to restart the app since it support hot reload thanks to Viper

Known Limitation

  • Only support JSON response
  • Does not support auth. so anyone can hit the endpoint and get the JSON response
  • Does not support any request validation (future development)
  • Does not support giving multiple responses in single endpoint. say you want give response either 200 or 400 according to request in single endpoint

License

This project is licensed under the MIT License - see the LICENSE file for details.

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