0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 16:00:19 -05:00
penpot/backend/uxbox/router.clj
2015-12-30 00:18:59 +02:00

41 lines
1.1 KiB
Clojure

(ns uxbox.router
(:refer-clojure :exclude [error-handler])
(:require [uxbox.impl.routing :as rt]
[com.stuartsierra.component :as component]
[catacumba.components :refer (catacumba-server assoc-routes!)]
[cats.core :as m]
[promissum.core :as p]))
(defmulti handler
(fn [context frame]
[(:cmd frame)
(:dest frame)]))
;; (defmethod handler [:novelty :auth]
;; [context frame]
;; (let [state (:state context)
;; body (:body frame)]
;; (m/mlet [user (authenticate body)]
;; (swap! state assoc :user user)
;; (m/return (rt/response {:ok true})))))
;; (defmethod handler [:query :project]
;; [context frame]
;; (let [state (:state context)
;; body (:body frame)]
;; (m/mlet [proj (query-project body)]
;; (m/return (rt/response proj)))))
(defrecord WebComponent [config server]
component/Lifecycle
(start [this]
(let [routes [[:any "api" (rt/router handler)]]]
(assoc-routes! server ::web routes)))
(stop [this]
;; noop
))
(defn component
[]
(WebComponent. nil nil))