arcly-http 0.2.2

Enterprise-grade NestJS-inspired web framework on axum: zero-lock DI, declarative controllers, multi-tenant data routing, transactional outbox, ABAC, and a self-documenting OpenAPI surface
Documentation
//! Zero-axum public HTTP types.
//!
//! User code says `arcly_http::Response`, `arcly_http::Json`, etc. — no
//! `axum::…` paths in the public surface. Internally these are thin
//! delegations to axum, so we keep its battle-tested implementation without
//! welding it into the public API.
//!
//! Why a private `axum::response::Response` re-export rather than a full
//! newtype: pinning `axum::response::Response` is the *one* type the
//! framework's boundary code constructs; making it a newtype would force
//! every adapter / interceptor to unwrap repeatedly with zero behavioural
//! benefit. A `pub use` rename achieves the same "no axum in user paths"
//! outcome at zero runtime cost.

use serde::Serialize;

/// The framework's response type. Same memory shape as axum's; the alias
/// keeps the user-visible path `arcly_http::Response`.
pub use axum::response::Response;

/// Convert a value into a `Response`.
///
/// `arcly_http::IntoResponse` is a thin re-trait over axum's so user code
/// never types `axum`. A blanket impl makes every axum-compatible type
/// automatically satisfy ours.
pub trait IntoResponse: Sized {
    fn into_response(self) -> Response;
}

impl<T: axum::response::IntoResponse> IntoResponse for T {
    #[inline]
    fn into_response(self) -> Response {
        axum::response::IntoResponse::into_response(self)
    }
}

/// JSON response wrapper. `Json(body)` writes `Content-Type: application/json`
/// and serialises `body` with `serde_json`. Same surface as axum's `Json` so
/// the route macro's return-type walker (`Json<T> | Result<Json<T>, _>`)
/// keeps working without changes.
pub struct Json<T>(pub T);

impl<T: Serialize> axum::response::IntoResponse for Json<T> {
    #[inline]
    fn into_response(self) -> axum::response::Response {
        axum::response::IntoResponse::into_response(axum::Json(self.0))
    }
}

impl<T> From<T> for Json<T> {
    #[inline]
    fn from(v: T) -> Self {
        Json(v)
    }
}