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 3434 @cargo make --makefile Makefile.toml watch
3535.PHONY : dev
3636
37+ lint :
38+ @rustc -vV
39+ @cargo clippy --all-features -- -D warnings
40+ .PHONY : lint
41+
3742build :
3843 @rustc -vV
3944 @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] = [
88/// It applies the corresponding Cache-Control headers based on a set of file types.
99pub fn control_headers ( res : warp:: fs:: File ) -> warp:: reply:: WithHeader < warp:: fs:: File > {
1010 // 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 ;
1212
1313 if let Some ( ext) = res. path ( ) . extension ( ) {
1414 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) {
1616 max_age = 60 * 60 ;
1717 } else if CACHE_EXT_ONE_YEAR . iter ( ) . any ( |x| * x == ext) {
1818 max_age = 60 * 60 * 24 * 365 ;
@@ -34,5 +34,5 @@ pub fn control_headers(res: warp::fs::File) -> warp::reply::WithHeader<warp::fs:
3434
3535/// It caps a duration value at ~136 years.
3636fn 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
3838}
Original file line number Diff line number Diff line change @@ -7,9 +7,12 @@ use warp::{Rejection, Reply};
77pub async fn handle_rejection ( err : Rejection ) -> Result < impl Reply , Infallible > {
88 let code = if err. is_not_found ( ) {
99 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+ {
1114 StatusCode :: BAD_REQUEST
12- } else if let Some ( _ ) = err. find :: < warp:: reject:: MethodNotAllowed > ( ) {
15+ } else if err. find :: < warp:: reject:: MethodNotAllowed > ( ) . is_some ( ) {
1316 StatusCode :: METHOD_NOT_ALLOWED
1417 } else {
1518 StatusCode :: INTERNAL_SERVER_ERROR
You can’t perform that action at this time.
0 commit comments