|
@@ -7,23 +7,21 @@
|
|
|
[clj-tuple :as t])
|
|
|
(:gen-class))
|
|
|
|
|
|
-(defn plaintext-response
|
|
|
- []
|
|
|
+(def plaintext-response
|
|
|
(t/hash-map
|
|
|
:status 200
|
|
|
:headers (t/hash-map "content-type" "text/plain; charset=utf-8")
|
|
|
:body (bs/to-byte-array "Hello, World!")))
|
|
|
|
|
|
-(defn json-response
|
|
|
- []
|
|
|
+(def json-response
|
|
|
(t/hash-map
|
|
|
:status 200
|
|
|
:headers (t/hash-map "content-type" "application/json")))
|
|
|
|
|
|
(defn handler [{:keys [uri] :as req}]
|
|
|
(cond
|
|
|
- (= "/plaintext" uri) (plaintext-response)
|
|
|
- (= "/json" uri) (assoc (json-response)
|
|
|
+ (= "/plaintext" uri) plaintext-response
|
|
|
+ (= "/json" uri) (assoc json-response
|
|
|
:body (json/encode (t/hash-map :message "Hello, World!")))
|
|
|
:else {:status 404}))
|
|
|
|