Check upload size

This commit is contained in:
2024-05-14 12:04:53 +01:00
parent fc9263dc81
commit 30e4e8ed1c
3 changed files with 24 additions and 10 deletions

View File

@ -1,17 +1,18 @@
use std::ops::Sub;
use std::time::Duration;
use base64::prelude::BASE64_STANDARD;
use base64::Engine;
use base64::prelude::BASE64_STANDARD;
use log::info;
use nostr::{Event, JsonUtil, Kind, Timestamp};
use rocket::http::uri::{Absolute, Uri};
use rocket::http::Status;
use rocket::request::{FromRequest, Outcome};
use rocket::{async_trait, Request};
use rocket::http::Status;
use rocket::http::uri::{Absolute, Uri};
use rocket::request::{FromRequest, Outcome};
pub struct Nip98Auth {
pub content_type: Option<String>,
pub content_length: Option<usize>,
pub event: Event,
}
@ -95,6 +96,13 @@ impl<'r> FromRequest<'r> for Nip98Auth {
None
}
}),
content_length: request.headers().iter().find_map(|h| {
if h.name == "content-length" {
Some(h.value.parse().unwrap())
} else {
None
}
}),
})
} else {
Outcome::Error((Status::new(403), "Auth scheme must be Nostr"))