/
andrewslai.clj
40 lines (35 loc) · 1.28 KB
/
andrewslai.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
34
35
36
37
38
39
40
(ns andrewslai.clj.http-api.andrewslai
(:require [andrewslai.clj.http-api.admin :refer [admin-routes]]
[andrewslai.clj.http-api.articles :refer [articles-routes branches-routes compositions-routes]]
[andrewslai.clj.http-api.ping :refer [ping-routes]]
[andrewslai.clj.http-api.portfolio :refer [portfolio-routes]]
[andrewslai.clj.http-api.swagger :refer [swagger-ui-routes]]
[clojure.stacktrace :as stacktrace]
[compojure.api.sweet :refer [ANY api]]
[taoensso.timbre :as log]))
(defn exception-handler
[e data request]
(log/errorf "Error: %s, %s"
(ex-message e)
(stacktrace/print-stack-trace e)))
(def default-handler
(ANY "*" []
{:status 404}))
(defn andrewslai-app
[{:keys [http-mw] :as components}]
(api {:components components
:exceptions {:handlers {:compojure.api.exception/default exception-handler}}
:middleware [http-mw]}
ping-routes
articles-routes
branches-routes
compositions-routes
portfolio-routes
admin-routes
swagger-ui-routes
default-handler))
(comment
((andrewslai-app {:auth identity
:static-content nil})
{:request-method :get
:uri "hi"}))