Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/harshvishu/mocker
mock REST client for everyone
https://github.com/harshvishu/mocker
cli-app cli-tools http json mock mock-server rest rust rust-lang yaml
Last synced: 3 days ago
JSON representation
mock REST client for everyone
- Host: GitHub
- URL: https://github.com/harshvishu/mocker
- Owner: harshvishu
- License: mit
- Created: 2023-09-02T17:51:39.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-05T09:26:04.000Z (about 1 year ago)
- Last Synced: 2024-11-08T20:49:18.328Z (8 days ago)
- Topics: cli-app, cli-tools, http, json, mock, mock-server, rest, rust, rust-lang, yaml
- Language: Rust
- Homepage: https://crates.io/crates/moker
- Size: 1.09 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
- [x] Supports .json files
- [x] Supports headers (guard)
- [x] Supports all HTTP methods
- [x] Supports URL query parameters
- [ ] Supports body parameters (guard)
- [x] LRU Cache
- [x] Configurable through the command line
- [x] Network logger
- [x] File watcher
- [ ] Supports Swagger & Postman collection
- [ ] Supports socket
- [x] Supports .yaml files
- [ ] Distribution via binary
- [ ] Distribution via Homebrew## Usage
1. Clone the repository
2. Use the `cargo run` commandTo run the sample JSON files, use:
```bash
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](moker_workflow.png)### Build Status
[![Continuous integration](https://github.com/harshvishu/mocker/actions/workflows/build-and-release-linux.yml/badge.svg)](https://github.com/harshvishu/mocker/actions/workflows/build-and-release-linux.yml)