Better big form handling (#430)
* Allow customizing max form size from env vars * Add error page for unprocessable entities And change default http port to 7878 * Improve char counter: under the editor, more discrete, and give it a default value
This commit is contained in:
+17
-2
@@ -1,7 +1,8 @@
|
||||
use atom_syndication::{ContentBuilder, Entry, EntryBuilder, LinkBuilder, Person, PersonBuilder};
|
||||
use rocket::{
|
||||
http::{RawStr, uri::{FromUriParam, Query}},
|
||||
request::FromFormValue,
|
||||
http::{RawStr, Status, uri::{FromUriParam, Query}},
|
||||
Outcome,
|
||||
request::{self, FromFormValue, FromRequest, Request},
|
||||
response::NamedFile,
|
||||
};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -46,6 +47,20 @@ impl Page {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ContentLen(pub u64);
|
||||
|
||||
impl<'a, 'r> FromRequest<'a, 'r> for ContentLen {
|
||||
type Error = ();
|
||||
|
||||
fn from_request(r: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
|
||||
match r.limits().get("forms") {
|
||||
Some(l) => Outcome::Success(ContentLen(l)),
|
||||
None => Outcome::Failure((Status::InternalServerError, ())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Default for Page {
|
||||
fn default() -> Self {
|
||||
Page(1)
|
||||
|
||||
Reference in New Issue
Block a user