Improve formatting of ruma_wrapper.rs

This commit is contained in:
Jonas Platte 2021-04-23 19:04:59 +02:00 committed by Timo Kösters
parent d8b484beed
commit 026af6b1a6
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4

View File

@ -34,7 +34,8 @@ pub struct Ruma<T: Outgoing> {
pub body: T::Incoming, pub body: T::Incoming,
pub sender_user: Option<UserId>, pub sender_user: Option<UserId>,
pub sender_device: Option<Box<DeviceId>>, pub sender_device: Option<Box<DeviceId>>,
pub json_body: Option<Box<serde_json::value::RawValue>>, // This is None when body is not a valid string // This is None when body is not a valid string
pub json_body: Option<Box<serde_json::value::RawValue>>,
pub from_appservice: bool, pub from_appservice: bool,
} }
@ -124,14 +125,16 @@ where
} }
AuthScheme::ServerSignatures => { AuthScheme::ServerSignatures => {
// Get origin from header // Get origin from header
let x_matrix = match request let x_matrix = match request.headers().get_one("Authorization").map(|s| {
.headers() // Split off "X-Matrix " and parse the rest
.get_one("Authorization")
.map(|s| {
s[9..] s[9..]
.split_terminator(',').map(|field| {let mut splits = field.splitn(2, '='); (splits.next(), splits.next().map(|s| s.trim_matches('"')))}).collect::<BTreeMap<_, _>>() .split_terminator(',')
}) // Split off "X-Matrix " and parse the rest .map(|field| {
{ let mut splits = field.splitn(2, '=');
(splits.next(), splits.next().map(|s| s.trim_matches('"')))
})
.collect::<BTreeMap<_, _>>()
}) {
Some(t) => t, Some(t) => t,
None => { None => {
warn!("No Authorization header"); warn!("No Authorization header");