3

我想在我的 Suave 项目中使用会话状态。

我为“/home” url 启用会话状态,然后检查此状态是否存在:

#r @"packages\Suave.0.32.0\lib\net40\Suave.dll"

open Suave                 // always open suave
open Suave.Http.Successful // for OK-result
open Suave.Web            // for config 
open Suave.Http
open Suave.State.CookieStateStore
open Suave.Http.Applicatives
open Suave.Types

[ 
    path "/home" >>= statefulForSession >>= context  (fun x ->
                match HttpContext.state x with
                | Some state -> OK "session found"
                | None -> Suave.Http.RequestErrors.BAD_REQUEST "No Session Found"
            )]
|> choose
|> startWebServer defaultConfig 

每次访问“/home”时,都会以 BAD_REQUEST“No Session Found”结束。

我究竟做错了什么?

4

0 回答 0