gpt4 book ai didi

.net - 如何在 F# Suave 中路由/商店/类别/%s/品牌/%s?

转载 作者:行者123 更新时间:2023-12-02 12:01:00 25 4
gpt4 key购买 nike

我不知道如何为这样的路径设置路由器:

/store/category/%s/brand/%s

我有网上商店演示,它适用于简单的 URL,但我不知道如何进行更灵活的配置。

这就是我所拥有的:

type StrPath = PrintfFormat<(string -> string),unit,string,string,string>
// How do this?
type Str2Path = PrintfFormat<(string -> string),unit,string,string,string>

let withParam (key,value) path = sprintf "%s?%s=%s" path key value

module Store =
//Don't know what put here
let browseBrand = sprintf "/store/category/%s/brand/%s"
//This work ok
let browseCategory : StrPath = "/store/category/%s"
// I need to capture query parameters
let browseBrand cat brand = request (fun r ->
Views.browse(cat brand))

let webPart =
localizeUICulture >>
choose [
path Path.Store.overview >=> overview
pathScan Path.Store.browseBrand browseBrand
pathScan Path.Store.browseCategory browseCategory

最佳答案

那这个呢?

// note the string tuple as return value
type Str2Path = PrintfFormat<(string -> string -> string),unit,string,string,(string * string)>

module Store =
// your path
let browseBrand : Str2Path = "/store/category/%s/brand/%s"

// again, note the tuple as input
let browseBrand (cat, brand) = request (Views.browse(cat brand))

let webPart =
localizeUICulture >>
choose [
pathScan Store.browseBrand browseBrand
// ... OMMITED
]

关于.net - 如何在 F# Suave 中路由/商店/类别/%s/品牌/%s?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37623276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com