Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CLJS Routing
defresource contact [handlers]
:allowed-methods #{:delete :put}
:available-media-types #{"application/json"}
:handle-ok (fn [{{{id :id} :route-params routes :routes} :request}]
(assert (realized? handlers))
(html [:div [:h2 "Contact: " id]
[:a {:href (path-for routes (:contacts @handlers))} "Index"]])))
(defn make-handlers [database]
(let [p (promise)]
;; Deliver the promise so it doesn't escape this function.
@(deliver p {:contacts (contacts database p)
:contact (contact p)})))
(defn make-routes [handlers]
["/" [["contacts" (:contacts handlers)]
[["contact/" :id] (:contact handlers)]
]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.