Upgrade Ruma

This commit is contained in:
Jonas Platte 2022-02-12 02:06:30 +01:00
parent 9db0473ed5
commit 50b24b37c2
No known key found for this signature in database
GPG key ID: 7D261D771D915378
6 changed files with 34 additions and 32 deletions

View file

@ -3,7 +3,9 @@ use std::{collections::BTreeMap, iter::FromIterator, str};
use axum::{
async_trait,
body::{Full, HttpBody},
extract::{rejection::TypedHeaderRejectionReason, FromRequest, RequestParts, TypedHeader},
extract::{
rejection::TypedHeaderRejectionReason, FromRequest, Path, RequestParts, TypedHeader,
},
headers::{
authorization::{Bearer, Credentials},
Authorization,
@ -45,6 +47,7 @@ where
let metadata = T::Incoming::METADATA;
let db = DatabaseGuard::from_request(req).await?;
let auth_header = Option::<TypedHeader<Authorization<Bearer>>>::from_request(req).await?;
let path_params = Path::<Vec<String>>::from_request(req).await?;
let query = req.uri().query().unwrap_or_default();
let query_params: QueryParams = match ruma::serde::urlencoded::from_str(query) {
@ -281,11 +284,10 @@ where
debug!("{:?}", http_request);
let body =
<T::Incoming as IncomingRequest>::try_from_http_request(http_request).map_err(|e| {
warn!("{:?}", e);
Error::BadRequest(ErrorKind::BadJson, "Failed to deserialize request.")
})?;
let body = T::Incoming::try_from_http_request(http_request, &path_params).map_err(|e| {
warn!("{:?}", e);
Error::BadRequest(ErrorKind::BadJson, "Failed to deserialize request.")
})?;
Ok(Ruma {
body,