Parcourir la source

say-hi only runs at /hi, and resources are served (!!)

Harlan Iverson il y a 9 ans
Parent
commit
3beefa018c
2 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 4 7
      web-backend/src/example/core.clj
  2. 2 0
      web-backend/src/example/main.clj

+ 4 - 7
web-backend/src/example/core.clj

@@ -2,16 +2,13 @@
     (:require [ring.middleware.resource :refer [wrap-resource]]
               [org.httpkit.server :refer [run-server]]))
 
-(defn say-hi [req] false) ;{:status 200 :body "hi" :content-type "text/plain"}
+(defn say-hi [req]
+      (when (.startsWith (:uri req) "/hi")
+            {:status 200 :body "hi" :content-type "text/plain"}))
 
-(def appx (-> say-hi
+(def app (-> say-hi
              (wrap-resource "public")))
 
-(defn app [req] {:status 200 :body "hi" :content-type "text/plain"})
-
-
-
-
 (defn start! []
       (println "server on.")
       (run-server app {:port 8080}))

+ 2 - 0
web-backend/src/example/main.clj

@@ -2,5 +2,7 @@
     (:require [example.core :as core])
     (:gen-class))
 
+; this file exists as a shim between boot loading and reloadable core code. if the need to AOT goes away, this can too.
+
 (defn -main []
       (core/start!))