A better Rust ATProto crate

bugfix for axum extractor

Orual f91c371a 007ce354

Changed files
+30 -11
crates
jacquard-axum
src
+10
CHANGELOG.md
···
# Changelog
+
## `jacquard-axum` [0.4.2] - 2025-10-13
+
+
### Fixed
+
+
- Axum extractor now sets the correct Content-Type header during error path.
+
+
---
+
## [0.5.0] - 2025-10-13
### Added
···
- Minor improvements to derive macros (`jacquard-derive`)
- Identity resolution refinements (`jacquard-identity`)
- OAuth client improvements (`jacquard-oauth`)
+
+
---
## [0.4.0] - 2025-10-11
+20 -11
crates/jacquard-axum/src/lib.rs
···
//! [`IntoStatic`], avoiding the DeserializeOwned requirement of the Json axum extractor and similar.
use axum::{
-
Router,
+
Json, Router,
body::Bytes,
extract::{FromRequest, Request},
-
http::StatusCode,
+
http::{HeaderValue, StatusCode, header},
response::{IntoResponse, Response},
};
use jacquard::{
···
Ok(value) => Ok(ExtractXrpc(*value.into_static())),
Err(err) => Err((
StatusCode::BAD_REQUEST,
-
serde_json::to_string(&json!({
+
[(
+
header::CONTENT_TYPE,
+
HeaderValue::from_static("application/json"),
+
)],
+
Json(json!({
"error": "InvalidRequest",
"message": format!("failed to decode request: {}", err)
-
}))
-
.expect("Failed to serialize error response"),
+
})),
)
.into_response()),
}
···
serde_html_form::from_str::<R::Request<'_>>(query).map_err(|e| {
(
StatusCode::BAD_REQUEST,
-
serde_json::to_string(&json!({
+
[(
+
header::CONTENT_TYPE,
+
HeaderValue::from_static("application/json"),
+
)],
+
Json(json!({
"error": "InvalidRequest",
"message": format!("failed to decode request: {}", e)
-
}))
-
.expect("Failed to serialize error response"),
+
})),
)
.into_response()
})?;
···
} else {
Err((
StatusCode::BAD_REQUEST,
-
serde_json::to_string(&json!({
+
[(
+
header::CONTENT_TYPE,
+
HeaderValue::from_static("application/json"),
+
)],
+
Json(json!({
"error": "InvalidRequest",
"message": "wrong nsid for wherever this ended up"
-
}))
-
.expect("Failed to serialize error response"),
+
})),
)
.into_response())
}