Skip to content

Instantly share code, notes, and snippets.

@cldwalker
Forked from danneu/when-let-lol.clj
Last active December 30, 2015 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cldwalker/7896195 to your computer and use it in GitHub Desktop.
Save cldwalker/7896195 to your computer and use it in GitHub Desktop.
(defroutes chapter-routes
;; Example story-slug: 42-my-first-story
;; Example chapter-slug: 99-introduction
;; (util/parse-uid "42-my-first-story") -> 42
;; (util/parse-uid "99-introduction") -> 99
(GET "/chapters/:chapter-slug" [story-slug chapter-slug]
(let [story (some-> story-slug util/parse-uid db/find-story-by-uid)
chapter (some-> chapter-slug util/parse-uid db/find-chapter-by-uid)]
(and story chapter
(zizkov.views/show-chapter layout story chapter)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment