-
Notifications
You must be signed in to change notification settings - Fork 0
/
ping.clj
33 lines (28 loc) · 854 Bytes
/
ping.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(ns andrewslai.clj.http-api.ping
(:require [clojure.java.shell :refer [sh]]
[clojure.string :refer [trim]]
[compojure.api.sweet :refer [defroutes GET]]
[ring.util.http-response :refer [ok]]
[taoensso.timbre :as log]))
(def pom-path
"META-INF/maven/org.clojars.alai57/andrewslai/pom.properties")
(defn parse-pom
[pom-path]
(some->> (clojure.java.io/resource pom-path)
slurp
(#(clojure.string/split % #"\n|="))
(partition 2)
(map vec)
(into {})
clojure.walk/keywordize-keys))
(defn short-sha
[]
(-> (sh "git" "rev-parse" "--short" "HEAD")
:out
trim))
(defn get-version-details []
(or (parse-pom pom-path)
{:revision (short-sha)}))
(defroutes ping-routes
(GET "/ping" []
(ok (get-version-details))))