-
Notifications
You must be signed in to change notification settings - Fork 3
/
Checkout.fs
37 lines (31 loc) · 831 Bytes
/
Checkout.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module FreyaMusicStore.Checkout
open Arachne.Http
open Freya.Core
open Freya.Lenses.Http
open Freya.Machine
open Freya.Machine.Extensions.Http
open Freya.Router
let ok _ =
freya {
return! writeHtml ("checkout", () )
}
let post =
freya {
let ctx = Db.getContext()
let! a = getAuth
let userName = a.Value.UserName
Db.placeOrder userName ctx
}
let seeOther _ =
freya {
return! writeHtml ("checkoutComplete", () )
}
let pipe =
freyaMachine {
methodsSupported ( freya { return [ GET; POST ] } )
including common
including (protectAuthenticated [ GET; POST ] (Freya.init Uris.checkout))
postRedirect (Freya.init true)
handleSeeOther seeOther
handleOk ok
doPost post } |> FreyaMachine.toPipeline