Last active
September 26, 2016 13:02
-
-
Save stathissideris/e6c402c6b9c48cd5cb140cd64ebd79ff to your computer and use it in GitHub Desktop.
bidi verbose
This file contains 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
(defn leaf [fragment name] | |
[fragment name]) | |
(defn branch [fragment & children] | |
(let [[[tag param]] children] | |
(if (= tag :bidi/param) | |
[[fragment param] (vec (rest children))] | |
[fragment (vec children)]))) | |
(defn param [name] | |
[:bidi/param name]) | |
(def routes | |
(branch | |
"http://localhost:8080" | |
(branch "/users/" (param :user-id) | |
(branch "/topics" | |
(leaf "" :topics) | |
(leaf "/bulk" :topic-bulk))) | |
(branch "/topics/" (param :topic) | |
(leaf "" :private-topic)) | |
(leaf "/schemas" :schemas) | |
(branch "/orgs/" (param :org-id) | |
(leaf "/topics" :org-topics)))) | |
;;compiles to: | |
;; ["http://localhost:8080" | |
;; [[["/users/" :user-id] | |
;; [["/topics" [["" :topics] ["/bulk" :topic-bulk]]]]] | |
;; [["/topics/" :topic] [["" :private-topic]]] | |
;; ["/schemas" :schemas] | |
;; [["/orgs/" :org-id] [["/topics" [["" :org-topics]]]]]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment