https://github.com/ztroop/echoserve
Mock HTTP API Server
https://github.com/ztroop/echoserve
http-server mocking rust
Last synced: 4 months ago
JSON representation
Mock HTTP API Server
- Host: GitHub
- URL: https://github.com/ztroop/echoserve
- Owner: ztroop
- License: mit
- Created: 2024-02-06T02:32:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-25T03:41:53.000Z (about 1 year ago)
- Last Synced: 2026-02-14T19:15:40.472Z (5 months ago)
- Topics: http-server, mocking, rust
- Language: Rust
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# echoserve
[](https://github.com/ztroop/echoserve/actions/workflows/build.yml)
Echoserve is a mock API server that serves configurable responses based on a YAML configuration file. It supports static responses as well as response sequences for endpoints.
## Features
- Serve mock endpoints with configurable method, path, status, headers, and payload.
- Support for JSON, XML, HTML, and plain text responses.
- Sequence feature: endpoints can return a series of different responses in order.
- Simulated latency.
## Usage
```sh
cargo run -- --config examples/config.yml
```
### Command-line Options
- `-c, --config `: Path to the YAML configuration file.
- `-p, --port `: Port to listen on (default: 8080).
- `-a, --address `: Address to bind to (default: 127.0.0.1).
- `-l, --latency `: Simulated latency in milliseconds (default: 0).
## Configuration File Format
The configuration file is a YAML file containing a list of endpoint definitions. Each endpoint can specify a static response or a sequence of responses.
### Static Response Example
```yaml
- name: "Example Endpoint 1"
endpoint: "/example1"
method: "GET"
data:
format: "xml"
payload: |
12345
Data for the first example
status: 200
headers:
Custom-Header: "Value1"
```
### Sequence Response Example
```yaml
- name: "Sequence Example"
endpoint: "/sequence"
method: "GET"
sequence:
- data:
format: "json"
payload:
message: "First response"
status: 200
- data:
format: "json"
payload:
message: "Second response"
status: 200
- data:
format: "json"
payload:
message: "Final response"
status: 404
```
- On each request to `/sequence`, the next response in the sequence is returned. After the last response, the final response is repeated for subsequent requests.
### Not Found Example
```yaml
- name: "Not Found Example"
endpoint: "/notfound"
status: 404
```