forked from otto-de/tesla-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.clj
28 lines (25 loc) · 970 Bytes
/
page.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
(ns de.otto.tesla.mongo.example.page
(:require
[com.stuartsierra.component :as c]
[de.otto.tesla.stateful.routes :as routes]
[de.otto.status :as status]
[de.otto.tesla.stateful.app-status :as app-status]
[compojure.core :as compojure]
[de.otto.tesla.mongo.mongo :as mongo]
[hiccup.core :as hiccup]))
(defn content [self]
(let [x (mongo/find-one-checked! (:mongo self) "testcol" {})
_ (println x)]
(hiccup/html [:body [:h1 "One Thing that is in the mongo"]
[:pre (str x)]])))
(defrecord ExamplePage [mongo routes app-status]
c/Lifecycle
(start [self]
(routes/register-routes routes
[(compojure/GET "/example" [_] (content self))])
(app-status/register-status-fun app-status
(fn [] (status/status-detail :example-page :ok "page is always fine")))
self)
(stop [self]
self))
(defn new-example-page [] (map->ExamplePage {}))