我有一个简单的 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。实现这一目标的最简单方法是什么?
我是 Suave.io 作曲风格的新手。