mod contract;
mod extract;
mod pagination;
mod routes;
use axum::{
http::StatusCode,
response::{IntoResponse, Response},
};
pub use contract::{ApiDocument, ApiRouteInfo};
pub use extract::{Json, Path, Query};
pub use pagination::{Page, PageMeta, Paginated, Pagination, PaginationMeta};
pub use routes::{RouteInfo, Routes};
pub use schemars as schema;
pub use schemars::JsonSchema as ApiSchema;
use serde::Serialize;
#[derive(Debug, Clone)]
pub struct Created<T>(pub T);
impl<T: Serialize> IntoResponse for Created<T> {
fn into_response(self) -> Response {
(StatusCode::CREATED, Json(self.0)).into_response()
}
}
#[derive(Debug, Clone, Copy)]
pub struct NoContent;
impl IntoResponse for NoContent {
fn into_response(self) -> Response {
StatusCode::NO_CONTENT.into_response()
}
}
pub async fn health() -> Json<HealthResponse> {
Json(HealthResponse { status: "ok" })
}
#[derive(Debug, Serialize, ApiSchema)]
pub struct HealthResponse {
pub status: &'static str,
}