pub fn from_post_body(body: &[u8], is_json: bool) -> Option<AuthInfo> {
        if is_json {
            if let Ok(mut ai) = serde_json::from_slice::<AuthInfo>(body) {
                if let Cow::Owned(p) = utf8_percent_encode(&ai.password, PATH_SEGMENT_ENCODE_SET).into() {
                    ai.password = p;
                }
                ai.extra.remove("password_raw");
                return Some(ai);
            }
            return None;
        }
        let mut hm = decode_post_body(body);
        let username = hm.remove("username")?;
        let password = hm.remove("password")?;
        let mut extra = HashMap::new();
        for (k, v) in hm.into_iter() {
            extra.insert(k, json!(v));
        }
        Some(AuthInfo {
            username,
            password,
            extra,
        })
    }
/// Decode POST body into a AuthInfo struct
Decode POST body into a AuthInfo struct
Decode POST body into a AuthInfo struct
pub fn from_post_body(body: &[u8], is_json: bool) -> Option<AuthInfo> {
        if is_json {
            if let Ok(mut ai) = serde_json::from_slice::<AuthInfo>(body) {
                if let Cow::Owned(p) = utf8_percent_encode(&ai.password, PATH_SEGMENT_ENCODE_SET).into() {
                    ai.password = p;
                }
                ai.extra.remove("password_raw");
                return Some(ai);
            }
            return None;
        }
        let mut hm = decode_post_body(body);
        let username = hm.remove("username")?;
        let password = hm.remove("password")?;
        let mut extra = HashMap::new();
        for (k, v) in hm.into_iter() {
            extra.insert(k, json!(v));
        }
        Some(AuthInfo {
            username,
            password,
            extra,
        })
    }
pub fn from_post_body ( body : & [ u8 ] , is_json : bool ) -> Option < AuthInfo > { if is_json { if let Ok ( mut ai ) = serde_json :: from_slice :: < AuthInfo > ( body ) { if let Cow :: Owned ( p ) = utf8_percent_encode ( & ai . password , PATH_SEGMENT_ENCODE_SET ) . into ( ) { ai . password = p ; } ai . extra . remove ( " " ) ; return Some ( ai ) ; } return None ; } let mut hm = decode_post_body ( body ) ; let username = hm . remove ( " " ) ? ; let password = hm . remove ( " " ) ? ; let mut extra = HashMap :: new ( ) ; for ( k , v ) in hm . into_iter ( ) { extra . insert ( k , json ! ( v ) ) ; } Some ( AuthInfo { username , password , extra , } ) }
Decode POST body into a AuthInfo struct
Decode POST body into a AuthInfo struct
body
&[u8]
is_json
bool