File tree 2 files changed +24
-7
lines changed
2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change 1
1
{:deps
2
2
{org.clojure/clojure {:mvn/version " 1.11.3" }
3
- http-kit/http-kit {:mvn/version " 2.8.0" }}}
3
+ http-kit/http-kit {:mvn/version " 2.8.0" }
4
+ compojure/compojure {:mvn/version " 1.6.2" }
5
+ org.clojure/data.json {:mvn/version " 2.5.0" }}}
Original file line number Diff line number Diff line change 1
1
(ns kadai.core
2
- (:require [org.httpkit.server :as hk-server]))
2
+ (:require [compojure.core :refer [defroutes GET POST]]
3
+ [compojure.route :as route]
4
+ [org.httpkit.server :as hk-server]
5
+ [clojure.data.json :as json]))
3
6
4
- (defn app [_req]
5
- {:status 200
6
- :headers {" Content-Type" " text/html" }
7
- :body " hello HTTP!" })
7
+ (defn handle-health [req]
8
+ {:status 200
9
+ :headers {" Content-Type" " application/json" }
10
+ :body (json/write-str {:message " ok" })}
11
+ )
12
+
13
+ (defroutes all-routes
14
+ (GET " /healthz" [] handle-health)
15
+ ; ;(GET "/ws" [] chat-handler) ;; websocket
16
+ ; ;(GET "/async" [] async-handler) ;; asynchronous(long polling)
17
+ ; ; (context "/user/:id" []
18
+ ; ; (GET / [] get-user-by-id)
19
+ ; ; (POST / [] update-userinfo))
20
+ ; ; (files "/static/") ;; static file url prefix /static, in `public` folder
21
+ ; ;(not-found "<p>Page not found.</p>")) ;; all other, return 404
22
+ )
8
23
9
24
(defn start-server [_argc]
10
- (hk-server/run-server app {:port 8080 }))
25
+ (hk-server/run-server all-routes {:port 8080 }))
You can’t perform that action at this time.
0 commit comments