From 23c77c79f3f081ca129e1eb44cc7d2e8a09f6444 Mon Sep 17 00:00:00 2001 From: meeg_leeto Date: Sat, 30 Apr 2022 00:20:44 +0100 Subject: [PATCH] fix: try to serve anything that doesn't match from the dir --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index f603a87..dd0c388 100644 --- a/src/main.rs +++ b/src/main.rs @@ -820,9 +820,6 @@ async fn serve() { let slug_factory: &'static slug::SlugFactory = Box::leak(Box::new(slug_factory)); let db: &'static db::SlugDatabase = Box::leak(Box::new(db)); - // GET / - let homepage = warp::path::end().and(config.serve_rules.dir.to_filter()); - // POST /shorten/ with link in argument let shorten = warp::post() .and(warp::path("shorten")) @@ -858,7 +855,12 @@ async fn serve() { } }); - let get_routes = warp::get().and(homepage.or(link)); + // GET / + // This should be the last thing matched, so that anything that doesn't + // match another filter will try to match a file. + let homepage = warp::get().and(config.serve_rules.dir.to_filter()); + + let get_routes = warp::get().and(link.or(homepage)); let post_routes = warp::post().and(shorten); let routes = get_routes.or(post_routes);