I'm playing around with afBedSheet and wish to handle all requests to a directory. eg a request to /abcd calls abcdMethod#doSomething
I have the routes set up as
@Contribute { serviceId="Routes" }
static Void contributeRoutes(OrderedConfig conf) {
conf.add(Route(`/abcd/?`, abcdMethod#doSomething))
}
Yet when I browse to /abcd I get 404 errors :(
How do I make this work?
Ensure your route handler method
doSomething()does NOT take any arguments. For example, save the following asExample.fan:And run it with:
(Appending
-env devwill list all available routes on the 404 page.)Because
/abcd/?has a trailing?, it will match both the file URL ofhttp://localhost:8080/abcdand the directory URL ofhttp://localhost:8080/abcd/. But note it will not match any URLs inside/abcd.To match files inside
/abcd, add a Uri parameter to your route method (to capture the path) and change your route to:For example: