diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 3d5398b..1955963 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,8 +26,12 @@ fn get_message(id: usize, db: &State<SharedDB>) -> Json<Response<Message, &'stat } #[get("/get_message_id_list/<id_start>/<id_end>")] fn get_message_id_list(id_start: u64, id_end: u64, db: &State<SharedDB>) -> Json<Response<Vec<UID>, &'static str>> { - if id_end - id_start > 25 { + let delta = id_end as i128 - id_start as i128; + + if delta > 25 { return Json(Response(Err("Request limit is 25"))) + } else if delta < 0 { + return Json(Response(Err("Request range is less than 0"))) } let lock = db.sdb.lock().unwrap(); @@ -41,8 +45,12 @@ fn get_message_id_list(id_start: u64, id_end: u64, db: &State<SharedDB>) -> Json } #[get("/get_message_list/<id_start>/<id_end>")] fn get_message_list(id_start: u64, id_end: u64, db: &State<SharedDB>) -> Json<Response<Vec<Message>, &'static str>> { - if id_end - id_start > 25 { + let delta = id_end as i128 - id_start as i128; + + if delta > 25 { return Json(Response(Err("Request limit is 25"))) + } else if delta < 0 { + return Json(Response(Err("Request range is less than 0"))) } let lock = db.sdb.lock().unwrap(); |