Skip to content

Instantly share code, notes, and snippets.

@CallumVass
Created June 27, 2020 17:18
Show Gist options
  • Save CallumVass/e42c92b70247969282858bb58e62dd62 to your computer and use it in GitHub Desktop.
Save CallumVass/e42c92b70247969282858bb58e62dd62 to your computer and use it in GitHub Desktop.
time1 will return the time the server started and won't change, ie will always be 27/06/2020 18:16:59
time2 will work as I expected it to work, showing the current time the page was loaded
open System
open Saturn.Application
open Saturn.Router
open Giraffe.ResponseWriters
let time () = DateTime.Now.ToString()
let timeHandler next context =
text (time ()) next context
let routes = router {
get "/time1" (text (time()))
get "/time2" timeHandler
}
let app = application {
use_router routes
}
[<EntryPoint>]
let main argv =
run app
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment