浏览代码

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

Harlan Iverson 9 年之前
父节点
当前提交
3beefa018c
共有 2 个文件被更改,包括 6 次插入7 次删除
  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!))