1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Can check if a file is present in the request

This commit is contained in:
2020-06-20 14:06:59 +02:00
parent ca82924b85
commit a02dc8b7fa
3 changed files with 13 additions and 3 deletions

View File

@ -160,7 +160,6 @@ impl HttpRequestHandler {
pub fn has_post_parameter(&self, name: &str) -> bool {
self.body.contains_key(name)
}
/// Get a post parameter
pub fn post_parameter(&mut self, name: &str) -> ResultBoxError<&RequestValue> {
if !self.has_post_parameter(name) {
@ -252,6 +251,12 @@ impl HttpRequestHandler {
}
}
/// Check out whether a file was included in the request or not
pub fn has_file(&self, name: &str) -> bool {
if let Some(RequestValue::File(_, _)) = self.body.get(name) { true } else { false }
}
/// Get an integer included in the POST request
pub fn post_i64(&mut self, name: &str) -> ResultBoxError<i64> {
Ok(self.post_string(name)?.parse::<i64>()?)