4
我有形式簡單Suave.io服務器最簡單的方法:什麼是檢查傳入的請求中包含一定的標頭值
let Ok o = o |> JsonConvert.SerializeObject |> Successful.OK
let NotOk o = o |> JsonConvert.SerializeObject |> RequestErrors.BAD_REQUEST
type Result<'T> =
| Success of 'T
| Failure of string
let DoThing someParam anotherParam =
let stats = Success(999) // <- business code here
match stats with
| Success s -> s |> Ok
| Failure m -> m |> NotOk
...
let app =
choose
[ GET >=> choose
[
pathScan "/someroute/%i/%i" (fun (p1, p2) ->
DoThing p1 p2)
]
]
startWebServer config app
0
我想檢查請求包含一個頭一個特定的名稱和值,並且當NotOk缺失或不正確時返回NotOk。達到此目的最簡單的方法是什麼?
我是Suave.io的作曲風格的新人。
你可以看看:http://stackoverflow.com/questions/31672110/suave-io-using-pathscan-and-request-together。我認爲你可以檢查這個請求。注意:'type WebPart = HttpContext - > Async'和'type HttpContext = {request:HttpRequest;響應:HttpResponse}'。所以你需要打開'WebPart'。 –
halcwb