From 7d332b7c31b5818280a17b7fb532fd1ba1cdd252 Mon Sep 17 00:00:00 2001 From: neri Date: Fri, 14 Apr 2023 10:00:44 +0200 Subject: [PATCH] feat: allow http head requests --- src/main.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4d146b7..345d783 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,24 +80,27 @@ async fn main() -> std::io::Result<()> { .app_data(db.clone()) .app_data(expiry_watch_sender.clone()) .app_data(config.clone()) - .service(web::resource("/").route(web::get().to(upload::index))) + .service( + web::resource("/") + .route(web::get().to(upload::index)) + .route(web::head().to(upload::index)), + ) .service(web::resource("/upload").route(web::post().to(upload::upload))) .service( web::resource(["/upload/{id}", "/upload/{id}/{name}"]) - .route(web::get().to(upload::uploaded)), + .route(web::get().to(upload::uploaded)) + .route(web::head().to(upload::uploaded)), ) .service(Files::new("/static", "static").disable_content_disposition()) .default_service(web::route().to(not_found)) .service( - web::resource([ - "/{id:[a-z0-9]{5}}", - "/{id:[a-z0-9]{5}}/{name}", - ]) - .wrap(Condition::new( - config.enable_rate_limit, - Governor::new(&governor_conf), - )) - .route(web::get().to(download::download)), + web::resource(["/{id:[a-z0-9]{5}}", "/{id:[a-z0-9]{5}}/{name}"]) + .wrap(Condition::new( + config.enable_rate_limit, + Governor::new(&governor_conf), + )) + .route(web::get().to(download::download)) + .route(web::head().to(download::download)), ) } })