akas for localhost

dev-nonsettable
Matthew Butterick 4 years ago
parent c6411231c1
commit 53ffc88be0

@ -58,15 +58,16 @@
;; print message to console about a request ;; print message to console about a request
(define/contract (logger req) (define/contract (logger req)
(request? . -> . void?) (request? . -> . void?)
(define localhost-client "::1") (define localhost-names '("::1" "fe80::1%lo0" "127.0.0.1"))
(define url-string (url->string (request-uri req))) (define url-string (url->string (request-uri req)))
(unless (ends-with? url-string "favicon.ico") (unless (ends-with? url-string "favicon.ico")
(message (match url-string (message (match url-string
[(regexp #rx"/$") (string-append url-string " directory default page")] [(regexp #rx"/$") (string-append url-string " directory default page")]
[_ (string-replace url-string (setup:main-pagetree) " dashboard")]) [_ (string-replace url-string (setup:main-pagetree) " dashboard")])
(match (request-client-ip req) (match (request-client-ip req)
[(== localhost-client) ""] [client #:when (not (member client localhost-names))
[client (format "from ~a" client)])))) (format "from ~a" client)]
[_ ""]))))
;; pass string args to route, then ;; pass string args to route, then
;; package route into right format for web server ;; package route into right format for web server

@ -1 +1 @@
1587564275 1587667269

Loading…
Cancel
Save