Add $https parsing, fix time parsing

This commit is contained in:
Emelie Graven 2022-02-19 22:45:52 +01:00
parent e5d612223b
commit bb740067f1
Signed by: emelie
GPG key ID: C11123726DBB55A1

View file

@ -17,11 +17,11 @@ pub struct RawRequest {
host: String,
user_agent: String,
referrer: String,
secure: bool,
secure: String,
timestamp: String,
}
//#[derive(Serialize)]
#[derive(Debug)]
pub struct Request {
size: i32,
path: String,
@ -93,8 +93,12 @@ async fn receive_message(pool: &PgPool, message: &[u8]) -> Result<(), Box<dyn st
host: req.host,
user_agent: req.user_agent,
referrer: req.referrer,
secure: req.secure,
timestamp: OffsetDateTime::parse(req.timestamp, "%d/%m/%Y:%T %z")?
secure: match req.secure.as_str() {
"on" => true,
"" => false,
_ => return Err(String::from("Unexpected content in $https").into()),
},
timestamp: OffsetDateTime::parse(req.timestamp, "%d/%b/%Y:%T %z")?
};
db::insert(pool, req).await?;
Ok(())