Kurl.FmtURL request formatters.
TODO
Kurl as Fmt_url or Urlf or Urlfmt or Url_fmt ?val empty :
?disable_rel:bool ->
?use_exts:bool ->
?scheme:string ->
?authority:string ->
root:Webs.Http.Path.t ->
unit ->
fmtempty ~disable_rel ~use_exts ~scheme ~host ~root () is an empty URL formatter with:
scheme, a scheme used for full URL formatting, see req.host, a host used for full URL formatting, see req.root, the root path prepended to all URL request paths.use_exts, appends the extension of bare URLs to formatted URLs, defaults to false and expands directory indexes if requested by kind, see kind.disable_rel turns relative formatting functions into absolute ones (defaults to false). true is faster. The idea is to disable it for serving over the http[s] scheme and enable it for serving over the file scheme.This empty URL formatter has any bound on the root. This means that untyped URL formatting is readily available. For example via:
let url uf path = Kurl.Url.url uf Kurl.(V (any, Bare.v `GET path))val with_fmt :
?disable_rel:bool ->
?use_exts:bool ->
?scheme:string ->
?authority:string ->
?root:Webs.Http.Path.t ->
fmt ->
fmtwith_fmt uf is uf with formatter parameters changed as specified. See Fmt.empty.
val scheme : fmt -> stringscheme uf is the scheme of uf, can be empty.
val authority : fmt -> stringauthority uf is the authority of uf, can be empty.
val root : fmt -> Webs.Http.Path.troot uf is the root path of uf.
val disable_rel : fmt -> booldisable_rel uf is true if relative formatting is turned into absolute formatting.
val use_exts : fmt -> booluse_exts uf is true if bare URL extensions are appended to formatted URLs.
val bind : Webs.Http.Path.t -> 'a kind -> fmt -> fmtbind p k uf is uf with URL requests of kind k bound to well-formed path p.
Raises Invalid_argument if k is already bound in uf or if p not well-formed.
bind_tree t uf is uf with URL request kinds in t bound to their path in t.
bare uf (V (k, u)) is k's bare absolute URL request for u. Note that this differs from k's encoding only in the URL path.
Raises Invalid_arg if k is not part of fmt's tree.
val req : ?full:bool -> fmt -> kurl -> Webs.Http.Method.t * stringreq is like Fmt.bare' but returns an encoded URL path and query (if any).
If full is true (defaults to false) a complete URL is returned:
scheme: is prepended iff scheme is non empty.// follows iff both scheme and authority are non empty or if authority is empty and scheme is "file".authority follows iff authority is non empty.In general it's better to avoid full URLs if you can, but it can be useful e.g. for sitemap generation.
rel_bare rf ~src ~dst s is a relative raw request from src to dst. Compared to Fmt.bare this only changes the path of the result which is the relative path from src to dst.
Note this assumes both paths do not have dot or non-final empty segments.
Raises Invalid_arg if root or sub is not part of fmt's tree.
val rel_req : fmt -> src:kurl -> dst:kurl -> Webs.Http.Method.t * stringrel_req is like rel_bare but returns an encoded URL path, including the query (if any).