for example, the following code inside a router computation exppression
get "/time" (warbler (fun _ -> System.DateTime.Now.ToString("HH:mm:ss") |> sprintf "Time now is %s" |> text))
seems to have exactly the same effect as
forward "/time" (warbler (fun _ -> System.DateTime.Now.ToString("HH:mm:ss") |> sprintf "Time now is %s" |> text))
In both cases, the current time is displayed whenever a client navigates to /time.
In what situations will these be different?
you can supply any
HttpHandlertoforward, so it doesn't surprise me that you see this behavior. Whereforwardbecomes really useful is for nesting entire sub-routersunder a certain path root. In this case, forward makes sure that the routes under the child path match only on the sub-portions of the route.For example, take this setup:
In this case, the full path to the routerA get method would be
/hi/foo, not/foo.