Suave.io: using pathScan and request together

落花浮王杯 提交于 2019-12-01 03:06:47

问题


I'm just getting up and running with Suave.io. I'm sure this will become clearer as I dig more into Applicatives - but from a high level I can't see how to write a pathScan rule that applies the request applicative too. All examples I'm found only do one or the other. In both cases they are applied to a function taking arguments - so presumably the arguments would be combined somehow too.


回答1:


Both pathScan and request take a function that produces a web part, so they cannot be nicely chained using >>=. Instead, you can nest one inside the other (I think the order does not really matter here):

pathScan "/some/%d" (fun num ->
  request (fun r -> 
    OK(sprintf "%d - %A" num r.url)))


来源:https://stackoverflow.com/questions/31672110/suave-io-using-pathscan-and-request-together

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!