From d576ce419f7c1af54adbc3cfb13acbd1f37b0dbc Mon Sep 17 00:00:00 2001 From: James Wilson Date: Sat, 25 Jan 2020 14:07:32 +0000 Subject: [PATCH] Fix examples and add a couple more tests --- src/examples.rs | 4 ++-- src/routes.rs | 27 ++++++++++++--------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/examples.rs b/src/examples.rs index e873425..e2e7287 100644 --- a/src/examples.rs +++ b/src/examples.rs @@ -116,12 +116,12 @@ Declare routes that do nothing using \"nothing\" (can be useful for scripted use # http://localhost:8080/1/2/3/api/foo => ./files/foo.json # http://localhost:8080/wibble/api/foo => ./files/foo.json # http://localhost:8080/bar/api/foo => ./files/foo.json -# http://localhost:8080/api/foo => No route matches this".white() +# http://localhost:8080/api/foo => No route matches this".white(), example9="# Pick a specific status code (only valid HTTP status codes are allowed): weave 8080 to statuscode://403 # The alias \"nothing\" returns a 404 Not Found status: -weave 8080 to nothing" +weave 8080 to nothing", example10="weave nothing and 8080 to 9090" diff --git a/src/routes.rs b/src/routes.rs index 60ca30b..78bc073 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -202,21 +202,18 @@ mod test { ], 0 ), - // // "nothing" can take the palce of a destination (it'll return 404): - // ( - // vec![ - // s("nothing"), s("to"), s("9090"), s("and"), - // s("8081"), s("to"), s("9091"), s("and"), - // s("nothing"), s("and"), - // s("nothing"), s("and"), - // s("8082"), s("to"), s("9092"), - // ], - // vec![ - // route("http://localhost:8081/", "http://localhost:9091"), - // route("http://localhost:8082/", "http://localhost:9092"), - // ], - // 0 - // ), + // "nothing" can take the place of a destination (it'll return 404): + ( + vec![ + s("8081"), s("to"), s("nothing"), s("and"), + s("8082"), s("to"), s("statuscode://403") + ], + vec![ + route("http://localhost:8081/", "statuscode://404"), + route("http://localhost:8082/", "statuscode://403"), + ], + 0 + ), ( vec![s("8080/foo/bar"), s("to"), s("9090/foo"), s("--more"), s("args")], vec![