xyncro / freya

Freya Web Stack - Meta-Package
https://freya.io
Other
330 stars 30 forks source link

access to cookies through lenses #102

Open theimowski opened 9 years ago

theimowski commented 9 years ago

currently to work with cookies I had to sth like between those lines:

let setSessionCartId cartId : Freya<unit> = (fun freyaState ->
        let ctx = Microsoft.Owin.OwinContext(freyaState.Environment)
        ctx.Response.Cookies.Append("cartId", cartId)
        async.Return ((), freyaState)
    )

let getSessionCartId : Freya<string option> = (fun freyaState ->
        let ctx = Microsoft.Owin.OwinContext(freyaState.Environment)
        let cartId = 
            match ctx.Request.Cookies.["cartId"] with
            | null -> None
            | x -> Some x
        async.Return (cartId, freyaState)
    )

It would be nice to do the same with lenses

panesofglass commented 9 years ago

Note for @kolektiv: you may already know this, but the request header for cookies is Cookie, while the response header is Set-Cookie.

kolektiv commented 9 years ago

Funnily enough, I'd just reminded myself of the spec this morning! I might get a draft of cookies in to Arachne tonight, which will be good. It won't solve the original problem, I want to have a proper look at the best way to use things like the Microsoft.Owin middleware in cases like this, but it'll be a good step to sensible completeness.

kolektiv commented 9 years ago

This issue is currently in progress - feel free to track/watch https://github.com/kolektiv/arachne/tree/feature/cookies