-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcore.clj
30 lines (24 loc) · 796 Bytes
/
core.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
(ns app.core
(:require [ring.middleware.defaults :refer :all]
[ring.middleware.json :refer :all]
[tripod.core :as tripod]))
(defn home [req]
{:status 200 :body {:message "Home"}})
(defn away [req]
{:status 200 :body {:message (format "Away. Here's home with some extra params %s" (tripod/path-for ::home {:foo "bar"}))}})
(defn not-found [req]
{:status 200 :body {:message (format "Not here, try %s" (tripod/path-for ::away))}})
(def routes
(tripod/expand-routes
[["/" home
["/away" away]
["/*not-found" not-found]]]))
(def service
(-> {::tripod/routes routes}
tripod/default-interceptors
tripod/service))
(def handler
(-> service
(wrap-json-response)
(wrap-json-body)
(wrap-defaults api-defaults)))