apimock-rs
Summary
HTTP server generating REST/JSON responses. Aims to be mocking helper to develop microservices and APIs. Written in Rust and based on hyper.
Run ./apimock or ./apimock -c apimock.toml to start the server. It is single small native binary. Multiple platforms are supported and no installation is required.
Screenshots
Server started to listen:

curl test result:

Middleware is available as rhai script:

Features
1. Basic
- GET / POST methods
- Multiple
paths - Multiple .json/.json5 files treated as JSON Response
- based on hyper v1
2. Customization
- Custom HTTP response codes: 3xx as redirects, and 4xx and 5xx as errors
- Custom response headers which are reusable
- Can specify response time on all or each API path
- Middleware as
rhaiscript (ref: Rhai book (Statements chapter)) is available to customize request routing and response handling
3. Dynamic processing
- Flexible responses with patterns and jsonpath queries. Even with the same API URL path, multiple responses can be returned. See
url.paths_patterns - Dynamic path resolution with
dyn_data_dir
4. Safe and observable usage
- Validates configuration: Missing JSON files, duplicate paths etc.
- Prints out routing at startup
- Describes request content on both HTTP headers and body (json or plain text) when
verboselog is activated
5. Test helper
- Can switch data directory paths manually in testing via specific HTTP request to make json responses flexible
6. spawn feature
- With
spawnfeature activated, the server is available as subprocess. The output will be returned via tokio mpsc queue.
Reference
Acknowledgements
Depends on:
tokio / hyper / toml / serde / serde_json / json5 / console / rhai. In addition, mdbook (as to workflows)