better health check.
This commit is contained in:
@@ -1,48 +1,56 @@
|
||||
(ns auto-ap.handler
|
||||
(:require [amazonica.core :refer [defcredential]]
|
||||
[auto-ap.routes.auth :as auth]
|
||||
[auto-ap.routes.clients :as clients]
|
||||
[auto-ap.routes.invoices :as invoices]
|
||||
[auto-ap.routes.reminders :as reminders]
|
||||
[auto-ap.routes.graphql :as graphql]
|
||||
[auto-ap.routes.yodlee :as yodlee]
|
||||
[auto-ap.routes.events :as events]
|
||||
[auto-ap.routes.checks :as checks]
|
||||
[auto-ap.routes.exports :as exports]
|
||||
[auto-ap.routes.graphql :as graphql]
|
||||
[auto-ap.routes.invoices :as invoices]
|
||||
[auto-ap.routes.yodlee :as yodlee]
|
||||
[buddy.auth.backends.token :refer [jws-backend]]
|
||||
[buddy.auth.middleware :refer [wrap-authentication
|
||||
wrap-authorization]]
|
||||
[clojure.java.jdbc :as jdbc]
|
||||
[buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]
|
||||
[clojure.tools.logging :as log]
|
||||
[compojure.core :refer :all]
|
||||
[compojure.route :as route]
|
||||
[config.core :refer [env]]
|
||||
[clojure.tools.logging :as log]
|
||||
[unilog.context :as lc]
|
||||
[mount.core :as mount]
|
||||
[ring.middleware.edn :refer [wrap-edn-params]]
|
||||
[ring.middleware.gzip :refer [wrap-gzip]]
|
||||
[ring.middleware.multipart-params :as mp]
|
||||
[ring.middleware.params :refer [wrap-params]]
|
||||
[ring.middleware.reload :refer [wrap-reload]]
|
||||
[ring.middleware.gzip :refer [wrap-gzip]]
|
||||
[ring.util.response :as response]))
|
||||
[ring.util.response :as response]
|
||||
[unilog.context :as lc]))
|
||||
|
||||
(when (:aws-access-key-id env)
|
||||
(defcredential (:aws-access-key-id env) (:aws-secret-access-key env) (:aws-region env)))
|
||||
|
||||
(def running? (atom false))
|
||||
|
||||
(mount/defstate manage-running?
|
||||
:start (reset! running? true)
|
||||
:stop (reset! running? false))
|
||||
|
||||
(defroutes static-routes
|
||||
(GET "/" [] (response/resource-response "index.html" {:root "public"}))
|
||||
(route/resources "/")
|
||||
(routes (ANY "*" [] (response/resource-response "index.html" {:root "public"}))))
|
||||
|
||||
(defroutes health-check
|
||||
(GET "/health-check" []
|
||||
(if @running?
|
||||
{:status 200
|
||||
:body "Ok"}
|
||||
{:status 503
|
||||
:body "Application shut down"})))
|
||||
|
||||
(defroutes api-routes
|
||||
(context "/api" []
|
||||
exports/routes
|
||||
yodlee/routes
|
||||
invoices/routes
|
||||
clients/routes
|
||||
reminders/routes
|
||||
checks/routes
|
||||
graphql/routes
|
||||
auth/routes))
|
||||
auth/routes
|
||||
health-check))
|
||||
|
||||
|
||||
(def auth-backend (jws-backend {:secret (:jwt-secret env) :options {:alg :hs512}}))
|
||||
|
||||
Reference in New Issue
Block a user