Last active
January 4, 2016 02:19
-
-
Save mwmitchell/8554074 to your computer and use it in GitHub Desktop.
Wire routing DSL change
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
(def routes | |
["items" {:GET [items/all :as :list-items] | |
:POST [items/create :as :create-item | |
:some-metadata-key true]} | |
;; OR, skip the ":as" key and set the ID as the first value in the vector, followed by handler metadata: | |
[":id" {:GET [:show-item items/show] | |
:PUT [:update-item items/update | |
:some-metadata-key true] | |
;; Maybe set the metadata as the last value in the vector, a hash-map? | |
:DELETE [:delete-item items/delete | |
{:some-metadata-key true}] | |
;; Completely skip the route ID: | |
:PATCH items/update-attribute | |
;; Skip the route ID, but add metadata: | |
:HEAD [items/item-info {:some-metadata-key true}]}]]) | |
(get-route routes :update-item) | |
;; => {:method :PUT :path "/items/:id" :some-metadata-key true} | |
(path-for routes :update-item {:id 101}) | |
;; => "/items/101" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment