13 HTTP
(require koyo/http) | package: koyo-lib |
This module provides utilities for working with HTTP-related data structures.
procedure
(request-path req) → string?
req : request?
Returns the absolute request path for req, scrubbed of path params.
procedure
(bindings-ref bindings name [default]) → (or/c #f string?)
bindings : (listof binding?) name : symbol? default : (or/c #f string?) = #f
procedure
(bindings-ref-bytes bindings name [default]) → (or/c #f bytes?)
bindings : (listof binding?) name : symbol? default : (or/c #f bytes?) = #f
procedure
(bindings-ref-number bindings name [default]) → (or/c #f number?)
bindings : (listof binding?) name : symbol? default : (or/c #f number?) = #f
procedure
(bindings-ref-symbol bindings name [default]) → (or/c #f symbol?)
bindings : (listof binding?) name : symbol? default : (or/c #f symbol?) = #f
Finds the first binding in bindings whose name is
name and returns its value or default.
Removes all the path params from u, while leaving its path
intact. This is used by the default continuation mismatch handler
to strip the current URL of its continuation id.
> (require koyo/http net/url)
> (url->string (url-scrub (string->url "https://127.0.0.1/foo/bar;(\"k\" . \"123\")/baz"))) "https://127.0.0.1/foo/bar/baz"
Joins the scrubbed path params in u and returns the
resulting string.
Examples:
> (require koyo/http net/url) > (url-path* (string->url "https://example.com")) "/"
> (url-path* (string->url "https://example.com/")) "/"
> (url-path* (string->url "https://example.com/a/b/c")) "/a/b/c"
Added in version 0.21 of package koyo-lib.
procedure
(url-has-path? u p) → boolean?
u : url? p : string?
Returns #t when the scrubbed path of u matches
p.
Examples:
> (require koyo/http net/url) > (url-has-path? (string->url "https://example.com") "") #t
> (url-has-path? (string->url "https://example.com") "/") #t
> (url-has-path? (string->url "https://example.com/a") "/a") #t
> (url-has-path? (string->url "https://example.com/a/b/c") "/a/b/c") #t
> (url-has-path? (string->url "https://example.com/a/b/c") "a/b/c") #t
Added in version 0.21 of package koyo-lib.