Giraffe
Giraffe copied to clipboard
Allowing subRoute to match full path segments
In some cases, I would like to be able to use subRoute*
to match full path segments only, while also handling the case where the path matches exactly without a trailing /
.
When including a trailing /
in the path to subRoute
, it will match the path segments completely, but it won't handle the case where the trailing /
is omitted. Also, the new path in the provided handler will not have a leading /
.
To allow this new functionality, three new handlers can be created which would coincide with the three existing handlers.
let subDirRoute path next =
subRoute path (
choose [ route "" ; routeStartsWith "/" ] >=> next
)
let subDirRouteCi path next =
subRouteCi path (
choose [ route "" ; routeStartsWith "/" ] >=> next
)
let subDirRoutef path next =
subRoutef path (fun v ->
choose [ route "" ; routeStartsWith "/" ] >=> next v
)