From 1ba2f3e437281adef7b9ffdd724a13eb78a1d3a3 Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Sat, 22 Apr 2017 14:24:30 -0500 Subject: Add state-fn --- src/app/api.clj | 4 +--- src/app/handler.clj | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/api.clj b/src/app/api.clj index 0f7ab17..f3a4324 100644 --- a/src/app/api.clj +++ b/src/app/api.clj @@ -1,6 +1,4 @@ (ns app.api (:require [castra.core :refer [defrpc]])) -(defrpc get-state [] - {:inputs [] - :outputs []}) +(defrpc get-state []) diff --git a/src/app/handler.clj b/src/app/handler.clj index fdf722e..21d52ab 100644 --- a/src/app/handler.clj +++ b/src/app/handler.clj @@ -12,9 +12,13 @@ (c/GET "/" req (response/content-type (response/resource-response "index.html") "text/html")) (route/resources "/" {:root ""})) +(defn state-fn [] + {:temps @temp/temp + :pm (select-keys @pm/pm [:status :current])}) + (def app (-> app-routes - (castra/wrap-castra {:state-fn (fn [] "ohi")} 'app.api) + (castra/wrap-castra {:state-fn state-fn} 'app.api) (d/wrap-defaults d/api-defaults))) (db/init) -- cgit v1.2.3-18-g5258