[back/perf] server static files

This commit is contained in:
SouthFox 2023-08-25 19:01:46 +08:00
parent f42d851765
commit 97561beed8

View file

@ -1,6 +1,7 @@
(ns backend.core
(:require [ring.adapter.jetty :refer [run-jetty]]
[reitit.ring :as ring]
[ring.util.response :refer [resource-response]]
[backend.handlers :as handlers])
(:gen-class))
@ -8,18 +9,22 @@
(def app
(ring/ring-handler
(ring/router
[["/hp/:id" {:parameters {:path {:id int?}}
:get {:handler handlers/fetch-hu-post}}]])
(ring/create-default-handler
{:not-found (constantly {:status 404 :body "Not found"})})))
[["/" (constantly (resource-response "index.html" {:root "public"}))]
["/api"
["/hp/:id" {:parameters {:path {:id int?}}
:get {:handler handlers/fetch-hu-post}}]]])
(ring/routes
(ring/create-resource-handler {:path "/"})
(ring/create-default-handler
{:not-found (constantly {:status 404 :body "Not found"})}))))
(defn -main [& args]
(run-jetty #'app {:port 3000
:join? false}))
(def server (run-jetty #'app {:port 3000
:join? false}))
;; (def server (run-jetty #'app {:port 3000
;; :join? false}))
;; (.stop server)
;; (app {:request-method :get
;; :uri "/hp/431038004"
;; :uri "/api/hp/431038004"
;; })