2022-09-04 13:32:45 +00:00
|
|
|
#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"
|
2022-09-04 13:32:45 +00:00
|
|
|
"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)))))
|