From 0f2692e43cac41917d24a1da24a45ebb266b88ea Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Wed, 24 Jan 2024 17:16:03 +0100 Subject: It is unforunate that I have to do this It would be nicer if it would be somehow possible to tell the axum JSON extractor that I valdiate the content type myself. Or maybe I should just stop using the axum JSON extractor altogether, as it really isn't too complex. --- rs/server/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rs/server/src/main.rs b/rs/server/src/main.rs index b8428cb..cbac138 100644 --- a/rs/server/src/main.rs +++ b/rs/server/src/main.rs @@ -344,10 +344,11 @@ where { type Rejection = GitLfsJsonRejection; - async fn from_request(req: Request, state: &S) -> Result { + async fn from_request(mut req: Request, state: &S) -> Result { if !has_git_lfs_json_content_type(&req) { return Err(GitLfsJsonRejection::MissingGitLfsJsonContentType); } + req.headers_mut().insert(header::CONTENT_TYPE, HeaderValue::from_static("application/json")); Json::::from_request(req, state) .await .map(GitLfsJson) -- cgit v1.2.3