File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 34
34
@cargo make --makefile Makefile.toml watch
35
35
.PHONY : dev
36
36
37
+ lint :
38
+ @rustc -vV
39
+ @cargo clippy --all-features -- -D warnings
40
+ .PHONY : lint
41
+
37
42
build :
38
43
@rustc -vV
39
44
@cargo build --release --target $(PKG_TARGET )
Original file line number Diff line number Diff line change @@ -8,11 +8,11 @@ const CACHE_EXT_ONE_YEAR: [&str; 30] = [
8
8
/// It applies the corresponding Cache-Control headers based on a set of file types.
9
9
pub fn control_headers ( res : warp:: fs:: File ) -> warp:: reply:: WithHeader < warp:: fs:: File > {
10
10
// Default max-age value in seconds (one day)
11
- let mut max_age = 60 * 60 * 24 as u64 ;
11
+ let mut max_age = 60 * 60 * 24_u64 ;
12
12
13
13
if let Some ( ext) = res. path ( ) . extension ( ) {
14
14
if let Some ( ext) = ext. to_str ( ) {
15
- if CACHE_EXT_ONE_HOUR . iter ( ) . any ( |n | * n == ext) {
15
+ if CACHE_EXT_ONE_HOUR . iter ( ) . any ( |x | * x == ext) {
16
16
max_age = 60 * 60 ;
17
17
} else if CACHE_EXT_ONE_YEAR . iter ( ) . any ( |x| * x == ext) {
18
18
max_age = 60 * 60 * 24 * 365 ;
@@ -34,5 +34,5 @@ pub fn control_headers(res: warp::fs::File) -> warp::reply::WithHeader<warp::fs:
34
34
35
35
/// It caps a duration value at ~136 years.
36
36
fn duration ( n : u64 ) -> u32 {
37
- std:: cmp:: min ( n. clone ( ) , u32:: MAX as u64 ) as u32
37
+ std:: cmp:: min ( n, u32:: MAX as u64 ) as u32
38
38
}
Original file line number Diff line number Diff line change @@ -7,9 +7,12 @@ use warp::{Rejection, Reply};
7
7
pub async fn handle_rejection ( err : Rejection ) -> Result < impl Reply , Infallible > {
8
8
let code = if err. is_not_found ( ) {
9
9
StatusCode :: NOT_FOUND
10
- } else if let Some ( _) = err. find :: < warp:: filters:: body:: BodyDeserializeError > ( ) {
10
+ } else if err
11
+ . find :: < warp:: filters:: body:: BodyDeserializeError > ( )
12
+ . is_some ( )
13
+ {
11
14
StatusCode :: BAD_REQUEST
12
- } else if let Some ( _ ) = err. find :: < warp:: reject:: MethodNotAllowed > ( ) {
15
+ } else if err. find :: < warp:: reject:: MethodNotAllowed > ( ) . is_some ( ) {
13
16
StatusCode :: METHOD_NOT_ALLOWED
14
17
} else {
15
18
StatusCode :: INTERNAL_SERVER_ERROR
You can’t perform that action at this time.
0 commit comments