SuaveIO / suave

Suave is a simple web development F# library providing a lightweight web server and a set of combinators to manipulate route flow and task composition.
https://suave.io
Other
1.32k stars 198 forks source link

How do I get a cookie or cookies out of a context? #744

Closed njlr closed 4 years ago

njlr commented 4 years ago

Is there a better way than this?

fun ctx -> async {
  let cookies =
    Headers.getHeader "Cookie" ctx
    |> Seq.toList

  return!
    ctx
    |> Successful.OK (sprintf "Your cookies: %A" cookies)
}
ademar commented 4 years ago

How about this ?

open Cookie

fun ctx -> async {
  let cookies = ctx.request.cookies // need to open module Cookie 

  return!
    ctx
    |> Successful.OK (sprintf "Your cookies: %A" cookies)
}
njlr commented 4 years ago

Thanks, I was not aware of that module!