This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-20
Channels
- # announcements (2)
- # architecture (5)
- # beginners (118)
- # cider (5)
- # clara (13)
- # cljdoc (8)
- # cljs-dev (49)
- # cljsjs (2)
- # clojure (107)
- # clojure-dev (9)
- # clojure-europe (3)
- # clojure-italy (58)
- # clojure-japan (2)
- # clojure-nl (6)
- # clojure-spec (89)
- # clojure-uk (27)
- # clojurescript (9)
- # core-async (33)
- # cursive (2)
- # datascript (2)
- # datomic (31)
- # duct (4)
- # emacs (1)
- # events (1)
- # figwheel-main (1)
- # fulcro (69)
- # hoplon (7)
- # hyperfiddle (16)
- # incanter (4)
- # instaparse (4)
- # kaocha (1)
- # mount (2)
- # nrepl (19)
- # off-topic (40)
- # onyx (6)
- # other-languages (3)
- # pedestal (2)
- # re-frame (48)
- # reagent (2)
- # reitit (10)
- # ring-swagger (9)
- # shadow-cljs (63)
- # spacemacs (13)
- # sql (8)
Currently if you visit /api/leads/
with a trailing slash the app breaks because id is an empty string. How should I fortify my routes?
One option would be to test if id is empty and then do (layout/error-page {:status 404 title: "404 - Page not found"}
but I’m curious if there’s a better way.
@jayzawrotny bug in routing? I think the empty path parameter should not match to the path-parameter route?
(require '[compojure.core :as c])
((c/GET "/kikka/:id" [] "kikka") {:request-method :get, :uri "/kikka/1"})
; => {:status 200, :headers {"Content-Type" "text/html; charset=utf-8"}, :body "kikka"}
((c/GET "/kikka/:id" [] identity) {:request-method :get, :uri "/kikka/"})
; => nil