This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require [clojure.core.async | |
:refer [chan dropping-buffer thread <!! >!! >!]]) | |
(defmacro try! [ch & body] | |
`(let [ch# ~ch] | |
(try ~@body (catch Throwable t# | |
(when ch# (>! ch# t#)))))) | |
(defmacro try!! [ch & body] | |
`(let [ch# ~ch] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Higher-order fns that wrap handlers need to preserve the route metadata | |
;; No problem: just generate a version that does | |
(def for-host+ (preserve-routes for-host)) | |
(def make-REST-handlers+ (preserve-routes make-REST-handlers)) | |
;; Naming is optional can be arbitrarily deep in the tree as long as all | |
;; composition along the branch preserves route metadata. | |
;; This syntax is a rough first cut, another option is (GET :name "/" [] handler) | |
(def app | |
(routes (for-host+ "opp-admin.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns named-routes | |
(:require [compojure.core :as c]) | |
(:require [clojure.string :as str]) | |
(:import [java.net URLEncoder])) | |
(defn add-meta | |
"Merges metadata from maps ms into current metadata for obj." | |
[obj & ms] | |
(with-meta obj (apply merge (meta obj) ms))) |