moker

Crates.iomoker
lib.rsmoker
version0.1.3
sourcesrc
created_at2023-09-15 11:03:41.256729
updated_at2023-09-30 07:27:03.894576
descriptionA tool to run mock HTTP server using simple JSON or YAML files only
homepagehttps://github.com/harshvishu/mocker
repositoryhttps://github.com/harshvishu/mocker
max_upload_size
id973600
size1,450,978
हर्ष • Harsh • ハラシャ (harshvishu)

documentation

README

moker

A Simple Mock REST Client for Everyone

Main Objective

Moker allows you to easily run a mock server using JSON or YAML files.

Features

  • Supports .json files
  • Supports headers (guard)
  • Supports all HTTP methods
  • Supports URL query parameters
  • Supports body parameters (guard)
  • LRU Cache
  • Configurable through the command line
  • Network logger
  • File watcher
  • Supports Swagger & Postman collection
  • Supports socket
  • Supports .yaml files
  • Distribution via binary
  • Distribution via Homebrew

Usage

  1. Clone the repository
  2. Use the cargo run command

To run the sample JSON files, use:

cargo run -- -s ./example/json -p 8000

Flags

  • -s: Path to look for config files. Default is the root of the project (".")
  • -p: Port to run the mock server on. Default is 8080

JSON Configuration for Route

  • "name": An optional name for this configuration, used for logging purposes.
  • "method": Defines the allowed HTTP method/s for this URL. If set, only requests with specified methods will be processed; others will receive a "method not implemented" response. Can be a list of methods (e.g., ["get", "post"]). Ignore if you want to allow any HTTP method.
  • "headers": Define a dictionary/map of headers. The response will be sent only if the request contains these headers.

Response Configuration

Within the JSON body, use the "response" parameter to specify the following values:

  • "headers": Define a dictionary/map of headers to be included in the HTTP response.
  • "status_code": Set the HTTP response code.
  • "body": Provide the JSON or raw string you want to be returned in the HTTP response.
  • "delay_ms": Add a delay to the response in milliseconds.

Workflow

Workflow

Commit count: 63

cargo fmt