#json-response #mocking #testing #http-response #testing-http #https #api-response

bin+lib apimock

API mock Server generating HTTP/JSON responses written in Rust

19 stable releases

new 2.6.4 Jul 26, 2024
2.6.3 Jul 16, 2024
2.6.2 Jun 28, 2024
2.6.1 May 24, 2024
2.0.4 Mar 5, 2024

#660 in Web programming

Download history 14/week @ 2024-03-31 315/week @ 2024-05-12 1472/week @ 2024-05-19 33/week @ 2024-05-26 13/week @ 2024-06-02 17/week @ 2024-06-09 3/week @ 2024-06-16 148/week @ 2024-06-23 9/week @ 2024-06-30 91/week @ 2024-07-07 127/week @ 2024-07-14

375 downloads per month

ISC license

91KB
1K SLoC

apimock-rs

crates.io Documentation Dependency Status Releases Workflow License

Summary

Mocking helper to develop microservices and APIs. hyper-based HTTP server generating REST responses containing JSON ones. Written in Rust.

With small native binary, just run ./apimock or ./apimock -c apimock.toml to start the server !

Screenshots

Server started to listen:

server starts

curl test result:

server responds

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
  • Flexible responses with patterns and jsonpath queries. Even with the same API URL path, multiple responses can be returned. See url.paths_patterns
  • Can specify response time on all or each API path

3. Dynamic processing

4. Usability

  • 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 verbose log is activated

Reference

Acknowledgements

Depends on:

tokio / hyper / toml / serde / serde_json / json5 / console. In addition, mdbook (as to workflows)

Dependencies

~10–20MB
~274K SLoC