Hi Adam, thanks for the reply. How would [<EndPoint "/">] Anything of string help me? Could you give me a small sample?

By on 1/14/2016 12:44 AM ()

Well, maybe I misunderstand, I thought you were trying to catch all requests ("I am using string as an endpoint"), which can be multi-level (such as /users/kim), and you want to respond in a custom way to some without hardcoding any of the arguments (like "kim".)

If that's the case, you could create a "wildcard" pattern and examine the cases of interest. Something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
type EndPoint =
    | [<EndPoint "/root"; Wildcard>] Root of string list

module Site =

    [<Website>]
    let Main =
        Application.MultiPage (fun ctx endpoint ->
            match endpoint with
            | EndPoint.Root s ->
                match s with
                | [] ->
                    Content.Page(
                        div [text "This is the root page"]
                    )
                | [ "users"; user ] ->
                    Content.Page(
                        div [text ("Hello " + user + "!")]
                    )
                | s :: _ ->
                    Content.Page(
                        div [text ("This is the catch all page for " + s)]
                    )
        )

The only issue here is that you need to prefix all URLs with /root, such as /root, /root/users/kim, /root/whatever, etc. This could be solved if you could use [<EndPoint "/">] as I suggested.

By on 1/14/2016 4:30 AM ()

This would need an [<EndPoint "/">] Anything of string, which doesn't work as expected ATM. Let me take this up with the team to see how feasible it would be to implement.

By on 1/13/2016 6:01 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper