sorry this is such a long post
I am using F# and WebSharper (I am new to both technologies)
I have some endpoints defined (I have working code until I add the NotFound endpoint)
type EndPoint =
| [<EndPoint "/">] Home
| [<EndPoint "/login">] Login
| [<EndPoint "/about">] About
| [<EndPoint "/logout">] Logout
// trying to make a catch-all page handler
| [<EndPoint "/"; Wildcard>] NotFound of string
...
let HomePage ctx =
Templating.Main ctx EndPoint.Home "Home" [
// page stuff
]
let LoginPage ctx =
Templating.Main ctx EndPoint.Login "Login" [
h1 [] [text "Login Here"]
div [] [client <@ Client.LoginWidget() @>]
]
// other page constructs
let MissingPage ctx path =
Templating.Main ctx EndPoint.About "Page Not Found" [
h1 [] [text "404"]
p [] [text "The requested page could not be found"]
p [] [text path]
]
...
[<Website>]
let Main =
Application.MultiPage (fun ctx endpoint ->
match endpoint with
| EndPoint.Home -> HomePage ctx
| EndPoint.About -> AboutPage ctx
| EndPoint.Login -> LoginPage ctx
| EndPoint.Logout ->
async {
// call server-side code to log the user out
// what would i do here to redirect the user to the /login
// page
}
| EndPoint.NotFound path -> MissingPage ctx path
)
Add the NotFound endpoint messes up my other pages, for example, my home page starts getting handled by the MissingPage handler. which I can understand since the home page is set to match "/" and the not pattern is matching "/" wildcard, although I would have expected the single / to have matched the Home endpoint and anything else other than /Login /About and /Logout to have match the NotFound branch. But clearly, I do not understand something correctly.
So How can I get a "catch-all" type endpoint so that I can properly handle any path that is not explicitly catered for
the other thing that is messing up when I had the NotFound handling code is the Login handler no longer processes
div [] [client <@ Client.LoginWidget() @>]
And lastly, in the Logout handler, I want to call some server-side code (no problem) but what should I do to then redirect to a new web page, for example, to send the user back to the /login page?
Sorry again for such a long post Derek