diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-09-04 15:15:09 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-09-04 15:15:09 +0200 |
commit | bb1a876d5935d7122af471b27deee55cbd494d77 (patch) | |
tree | c4a93d1ee99127ad2b3595a51a74a841bc2febf8 | |
parent | 60f3660d0aa25f05241bef655a44e975919f21df (diff) |
Add check for computing not too many hours
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/frontend.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/frontend.rs b/src/frontend.rs index 2981249..964367e 100644 --- a/src/frontend.rs +++ b/src/frontend.rs @@ -91,6 +91,20 @@ pub async fn calculate(req: HttpRequest) -> Result<maud::Markup> { let ls: Landscape = config.deserialize_str(&req.query_string()) .map_err(|e| actix_web::error::ErrorInternalServerError(format!("{}", e)))?; + // TODO: We should propably error with 500 here, I'm not sure. + // This is just "good enough" for now. + if ls.hours > 1000 { + return Ok(maud::html! { + html { + body { + h1 { "Landscape error" } + + p { "Not gonna do that. Calculating " (ls.hours) " is way too resource intensive, please use a value below 1000" } + } + } + }) + } + let calculated_landscape = crate::backend::landscape::Landscape::new(ls.levels.clone()).rain(ls.hours); Ok(maud::html! { html { |