1use axum::{
2 Json,
3 http::{StatusCode, Uri, header},
4 response::IntoResponse,
5};
6
7pub type JsonBody<T> = Json<T>;
9pub type JsonPage<T> = Json<modkit_odata::Page<T>>;
10
11pub fn ok_json<T: serde::Serialize>(value: T) -> impl IntoResponse {
13 (StatusCode::OK, Json(value))
14}
15
16pub fn created_json<T: serde::Serialize>(
18 value: T,
19 uri: &Uri,
20 new_id: &str,
21) -> impl IntoResponse + use<T> {
22 let location = [uri.path().trim_end_matches('/'), new_id].join("/");
23 (
24 StatusCode::CREATED,
25 [(header::LOCATION, location)],
26 Json(value),
27 )
28}
29
30#[must_use]
32pub fn no_content() -> impl IntoResponse {
33 StatusCode::NO_CONTENT
34}