On this page:
29.1 Application URLs
current-application-url-scheme
current-application-url-host
current-application-url-port
make-application-url
29.2 Reverse Routing
current-reverse-uri-fn
reverse-uri

29 URLs

 (require koyo/url) package: koyo-lib

This module provides functions for generating URLs in your application.

29.1 Application URLs

parameter

(current-application-url-scheme)  (or/c "http" "https")

(current-application-url-scheme scheme)  void?
  scheme : (or/c "http" "https")
 = "http"

parameter

(current-application-url-host)  non-empty-string?

(current-application-url-host host)  void?
  host : non-empty-string?
 = "127.0.0.1"

parameter

(current-application-url-port)  (integer-in 0 65535)

(current-application-url-port port)  void?
  port : (integer-in 0 65535)
 = 8000
make-application-url uses these parameters when constructing URLs.

procedure

(make-application-url path-element    
  ...    
  [#:query query    
  #:fragment fragment])  string?
  path-element : string?
  query : (listof (cons/c symbol? string?)) = null
  fragment : (or/c false/c string?) = #f
Generates absolute URLs based on the given arguments.

29.2 Reverse Routing

This parameter holds the function that should be used to generate reverse URIs. Generally, you’ll take the reverse URI function that dispatch-rules+roles generates and stick it in here. reverse-uri will then proxy to it.

The default implementation raises an error.

procedure

(reverse-uri where [#:query query] arg ...)  string?

  where : symbol?
  query : (listof (cons/c symbol? (or/c #f string?))) = null
  arg : any/c
Applies the current-reverse-uri-fn to route and arg ....