mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 21:39:21 +00:00
Improve code readability
This commit is contained in:
parent
68055712d9
commit
5c938dccd1
@ -53,9 +53,9 @@ impl LimitPolicy {
|
|||||||
pub fn get_count(&self) -> u64 {
|
pub fn get_count(&self) -> u64 {
|
||||||
match self {
|
match self {
|
||||||
LimitPolicy::NONE => 0,
|
LimitPolicy::NONE => 0,
|
||||||
LimitPolicy::SUCCESS(n) => n.clone(),
|
LimitPolicy::SUCCESS(n) => *n,
|
||||||
LimitPolicy::FAILURE(n) => n.clone(),
|
LimitPolicy::FAILURE(n) => *n,
|
||||||
LimitPolicy::ANY(n) => n.clone(),
|
LimitPolicy::ANY(n) => *n,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ impl<'a> Stream for LimitedStream
|
|||||||
let res = Pin::new(self.stream.as_mut()).poll_next(cx);
|
let res = Pin::new(self.stream.as_mut()).poll_next(cx);
|
||||||
|
|
||||||
if let Poll::Ready(Some(Ok(d))) = &res {
|
if let Poll::Ready(Some(Ok(d))) = &res {
|
||||||
self.already_read = self.already_read + d.len();
|
self.already_read += d.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
@ -128,13 +128,13 @@ impl FromRequest for CustomRequest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Parse body arguments (following the pattern key1=value1&key2=value2)
|
// Parse body arguments (following the pattern key1=value1&key2=value2)
|
||||||
if body_str.len() > 0 {
|
if !body_str.is_empty() {
|
||||||
for v in body_str.split("&") {
|
for v in body_str.split('&') {
|
||||||
if v.len() == 0 {
|
if v.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let args: Vec<&str> = v.split("=").collect();
|
let args: Vec<&str> = v.split('=').collect();
|
||||||
|
|
||||||
if args.len() != 2 {
|
if args.len() != 2 {
|
||||||
return Err(actix_web::error::ErrorBadRequest(format!("{} is invalid!", args[0])));
|
return Err(actix_web::error::ErrorBadRequest(format!("{} is invalid!", args[0])));
|
||||||
|
Loading…
Reference in New Issue
Block a user