Skip to main content

mockd/
lib.rs

1//! Mockd — a lightweight standalone mock HTTP server.
2//!
3//! Mockd lets you stand up a realistic HTTP API from a declarative YAML
4//! configuration, without writing any code. It is designed for local
5//! development, integration tests and CI/CD pipelines.
6//!
7//! # Module overview
8//!
9//! - [`config`] — domain models and YAML configuration loading.
10//! - [`router`] — request matching against the configured routes.
11//! - [`template`] — `{{path.id}}` / `{{query.x}}` / `{{header.y}}` rendering.
12//! - [`server`] — the Axum HTTP layer.
13//!
14//! # Quick start
15//!
16//! ```no_run
17//! use mockd::{config::Config, server::Server};
18//!
19//! # async fn run() -> anyhow::Result<()> {
20//! let yaml = r#"
21//! listen: ":8080"
22//! routes:
23//!   - method: GET
24//!     path: /health
25//!     response:
26//!       status: 200
27//!       body:
28//!         ok: true
29//! "#;
30//! let config = Config::parse(yaml)?;
31//! let server = Server::from_config(config)?;
32//! server.serve().await?;
33//! # Ok(())
34//! # }
35//! ```
36
37#![forbid(unsafe_code)]
38
39pub mod config;
40pub mod router;
41pub mod server;
42pub mod template;
43
44pub use config::{Config, ConfigError};
45pub use router::{Match, Router, RouterError};
46pub use server::{build_app, Server, ServerError};