open OUnit2 open Piaf open Routes let static path_parts _db_pool _req = let path = Routes.Parts.wildcard_match path_parts in let full_path = "assets/" ^ path in Ok (Response.of_string ~body:full_path `OK) let routes = [ `GET, (s "assets" / wildcard) @--> static ] let test_wildcard _ = let router = one_of routes in let target = "/assets/foo/bar" in match match' router ~target with | FullMatch f -> let res = f () () in let body = Piaf.Body.to_string res.body in assert_equal "assets/foo/bar" body | _ -> assert_failure "No match" let suite = "wildcard" >::: [ "test_wildcard" >:: test_wildcard ] let () = run_test_tt_main suite