doido-controller 0.1.0

Action Controller + routing + Tower middleware for Doido: handlers, Context, responses, filters, routes! DSL, sessions, and middleware stacks.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use axum::{routing::get, routing::post, Router};
use doido_controller::testing::send;
use http::StatusCode;

#[tokio::test]
async fn send_drives_a_router_and_captures_the_response() {
    let app = Router::new()
        .route("/", get(|| async { "home" }))
        .route("/echo", post(|body: String| async move { body }));

    let home = send(app.clone(), "GET", "/", "").await;
    assert_eq!(home.status, StatusCode::OK);
    assert_eq!(home.body, "home");

    let echo = send(app, "POST", "/echo", "ping").await;
    assert_eq!(echo.body, "ping");
}