diff --git a/srv/content/router.hy b/srv/content/router.hy index 32c198b..85c82b8 100644 --- a/srv/content/router.hy +++ b/srv/content/router.hy @@ -83,18 +83,21 @@ #(param value))))))) (defn shtml-file-response [file [code 200] [template-params {}]] - (dict :code code :body (parse-html-file f"./www/site/html/{file}" #** template-params))) + (dict + :code code + :headers {"Connection" "keep-alive" "Keep-Alive" "timeout=5 max=200"} + :body (parse-html-file f"./www/site/html/{file}" #** template-params))) (defn raw-file-response [file [code 200]] (dict :code code #** (dict (zip ["headers" "body"] (send-raw-file f"./www/site/{file}"))))) (defn [(route "/" "GET")] /home #route-args (shtml-file-response "home.html")) (defn [(route "/html/*" "GET") (if-file-exists :base-path "./www/site/html" :otherwise (error 404 "not found"))] /html/* #route-args (shtml-file-response path)) -(defn [(route "/assets/*" "GET") (if-file-exists :base-path "./www/site/" :otherwise (error 404 "not found"))] /assets/* #route-args (raw-file-response path)) +(defn [lru-cache (route "/assets/*" "GET") (if-file-exists :base-path "./www/site/" :otherwise (error 404 "not found"))] /assets/* #route-args (raw-file-response path)) (defn [(route "/html/view-thought.html" "GET") (forward-params "thought" "filter-tag")] /html/view-thought #route-args [#** template-args] (shtml-file-response "/html/view-thought.html" :template-params template-args)) (defn [(route "/comment" "POST")] /comments #route-args (create-comment request)) -(defn [(route "/robots.txt" "GET") ] /robots #route-args (dict :code 200 :headers {"Content-Type" "text/plain"} :body "User-agent *\nDisallow: /\n")) +(defn [lru-cache (route "/robots.txt" "GET") ] /robots #route-args (dict :code 200 :headers {"Content-Type" "text/plain"} :body "User-agent *\nDisallow: /\n")) -(defn+ [lru-cache] match-request [{method "method" {path "path"} "route" :as request}] +(defn+ match-request [{method "method" {path "path"} "route" :as request}] ((get (routes.get-route-by-path path) method) method path request))