Skip to main content

Crate mockd

Crate mockd 

Source
Expand description

Mockd — a lightweight standalone mock HTTP server.

Mockd lets you stand up a realistic HTTP API from a declarative YAML configuration, without writing any code. It is designed for local development, integration tests and CI/CD pipelines.

§Module overview

  • config — domain models and YAML configuration loading.
  • router — request matching against the configured routes.
  • template{{path.id}} / {{query.x}} / {{header.y}} rendering.
  • server — the Axum HTTP layer.

§Quick start

use mockd::{config::Config, server::Server};

let yaml = r#"
listen: ":8080"
routes:
  - method: GET
    path: /health
    response:
      status: 200
      body:
        ok: true
"#;
let config = Config::parse(yaml)?;
let server = Server::from_config(config)?;
server.serve().await?;

Re-exports§

pub use config::Config;
pub use config::ConfigError;
pub use router::Match;
pub use router::Router;
pub use router::RouterError;
pub use server::build_app;
pub use server::Server;
pub use server::ServerError;

Modules§

config
Domain models and YAML configuration loading.
router
Route matching.
server
HTTP server layer (Axum).
template
Minimal template rendering for mockd responses.