Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(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]
(when-let [story-uid (util/parse-uid story-slug)]
(when-let [chapter-uid (util/parse-uid chapter-slug)]
(when-let [story (db/find-story-by-uid story-uid)]
(when-let [chapter (db/find-chapter-by-uid chapter-uid)]
(-> (zizkov.views/show-chapter story chapter)
layout))))))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.