breezewiki/src/page-subdomain.rkt

23 lines
662 B
Racket
Raw Normal View History

#lang racket/base
(require racket/path
racket/string
net/url
web-server/http
(prefix-in lift: web-server/dispatchers/dispatch-lift)
2022-09-09 03:42:20 +00:00
"application-globals.rkt"
"config.rkt"
"xexpr-utils.rkt")
(provide
subdomain-dispatcher)
(define (subdomain-dispatcher subdomain)
(lift:make
(λ (req)
(response-handler
(define uri (request-uri req))
(define path (url-path uri))
(define path-string (string-join (map (λ (p) (path/param-path p)) path) "/"))
(define dest (format "~a/~a/~a" (config-get 'canonical_origin) subdomain path-string))
2022-09-09 03:42:20 +00:00
(generate-redirect dest)))))