Skip to content

Instantly share code, notes, and snippets.

@mwmitchell
Last active January 4, 2016 02:19
Show Gist options
  • Save mwmitchell/8554074 to your computer and use it in GitHub Desktop.
Save mwmitchell/8554074 to your computer and use it in GitHub Desktop.
Wire routing DSL change
(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