Skip to content

Commit ab9bd4c

Browse files
committed
chore: basic implementation with healthz
1 parent e05ff94 commit ab9bd4c

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

backend-rest-clojure/deps.edn

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{:deps
22
{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"}}}
+21-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
(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]))
36

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+
)
823

924
(defn start-server [_argc]
10-
(hk-server/run-server app {:port 8080}))
25+
(hk-server/run-server all-routes {:port 8080}))

0 commit comments

Comments
 (0)