(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)))))) )