A better Rust ATProto crate

bugfix for axum extractor

+30 -11
+10
CHANGELOG.md
··· 1 1 # Changelog 2 2 3 + ## `jacquard-axum` [0.4.2] - 2025-10-13 4 + 5 + ### Fixed 6 + 7 + - Axum extractor now sets the correct Content-Type header during error path. 8 + 9 + --- 10 + 3 11 ## [0.5.0] - 2025-10-13 4 12 5 13 ### Added ··· 51 59 - Minor improvements to derive macros (`jacquard-derive`) 52 60 - Identity resolution refinements (`jacquard-identity`) 53 61 - OAuth client improvements (`jacquard-oauth`) 62 + 63 + --- 54 64 55 65 ## [0.4.0] - 2025-10-11 56 66
+20 -11
crates/jacquard-axum/src/lib.rs
··· 46 46 //! [`IntoStatic`], avoiding the DeserializeOwned requirement of the Json axum extractor and similar. 47 47 48 48 use axum::{ 49 - Router, 49 + Json, Router, 50 50 body::Bytes, 51 51 extract::{FromRequest, Request}, 52 - http::StatusCode, 52 + http::{HeaderValue, StatusCode, header}, 53 53 response::{IntoResponse, Response}, 54 54 }; 55 55 use jacquard::{ ··· 88 88 Ok(value) => Ok(ExtractXrpc(*value.into_static())), 89 89 Err(err) => Err(( 90 90 StatusCode::BAD_REQUEST, 91 - serde_json::to_string(&json!({ 91 + [( 92 + header::CONTENT_TYPE, 93 + HeaderValue::from_static("application/json"), 94 + )], 95 + Json(json!({ 92 96 "error": "InvalidRequest", 93 97 "message": format!("failed to decode request: {}", err) 94 - })) 95 - .expect("Failed to serialize error response"), 98 + })), 96 99 ) 97 100 .into_response()), 98 101 } ··· 104 107 serde_html_form::from_str::<R::Request<'_>>(query).map_err(|e| { 105 108 ( 106 109 StatusCode::BAD_REQUEST, 107 - serde_json::to_string(&json!({ 110 + [( 111 + header::CONTENT_TYPE, 112 + HeaderValue::from_static("application/json"), 113 + )], 114 + Json(json!({ 108 115 "error": "InvalidRequest", 109 116 "message": format!("failed to decode request: {}", e) 110 - })) 111 - .expect("Failed to serialize error response"), 117 + })), 112 118 ) 113 119 .into_response() 114 120 })?; ··· 116 122 } else { 117 123 Err(( 118 124 StatusCode::BAD_REQUEST, 119 - serde_json::to_string(&json!({ 125 + [( 126 + header::CONTENT_TYPE, 127 + HeaderValue::from_static("application/json"), 128 + )], 129 + Json(json!({ 120 130 "error": "InvalidRequest", 121 131 "message": "wrong nsid for wherever this ended up" 122 - })) 123 - .expect("Failed to serialize error response"), 132 + })), 124 133 ) 125 134 .into_response()) 126 135 }