Closed rbauduin closed 1 year ago
This largely by design, although I agree it's not the most ideal. I'd just make your endpoint take a single wildcard argument:
| [<EndPoint "/admin"; Wildcard>] Admin of args:list<string>
and pattern match on that:
open WebSharper.Sitelets.UrlHelpers
[<Website>]
let Main =
Application.MultiPage (fun ctx endpoint ->
match endpoint with
| EndPoint.Admin(["users"]) ->
Content.Text "Users page"
| EndPoint.Admin(["user"; INT i]) ->
Content.Text $"User's item {i} page"
...
Thanks for the suggestion, I have adopted it in my code.
I just don't understand the INT
in | EndPoint.Admin(["user"; INT i]) ->
. If it's not a typo it's something I don't know.
It's an active pattern defined in UrlHelpers
for extracting an integer from a string - a TryParse
, essentially.
Defining this endpoint;
Will require the presence of arguments. So it will handle
/admin/user/5
but notadmin/users
. To handle this last path I need to define an additional endpoint:It would be great if the first endpoint matched
/admin/users
too, giving an empty list of trailing elements.This would help when embedding a sitelet handling admin pages under the app's main sitelet (which is my use-case here)