I can't figure how setup the router for a path like:
/store/category/%s/brand/%s
I have the web store demo and it work for simple URLs, but I don't see how make more flexible configurations.
This is what I have:
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
And what about this?
// 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
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With