axum_duper 0.1.2

Axum extractor/response for Duper.
Documentation

Duper extractor / response for axum.

See the main project on GitHub.

Example

use axum::{Router, routing::post};
use axum_duper::Duper;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Deserialize)]
struct CreateUser {
    email: String,
    password: String,
}

#[derive(Serialize)]
struct UserResponse {
    id: Uuid,
}

async fn create_user(Duper(payload): Duper<CreateUser>) -> impl IntoResponse {
    let id = Uuid::new_v4();
    add_user_to_db(payload).await;
    Duper(UserResponse { id })
}

async fn add_user_to_db(user: CreateUser) {
    // ...
}

let app = Router::new().route("/users", post(create_user));