This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-17
Channels
- # adventofcode (56)
- # announcements (1)
- # aws (6)
- # beginners (127)
- # bristol-clojurians (1)
- # calva (29)
- # cider (7)
- # clj-kondo (37)
- # cljdoc (20)
- # cljsrn (7)
- # clojure (159)
- # clojure-europe (67)
- # clojure-italy (23)
- # clojure-nl (4)
- # clojure-provo (3)
- # clojure-uk (18)
- # clojurescript (19)
- # code-reviews (59)
- # community-development (105)
- # conjure (6)
- # core-async (16)
- # core-logic (1)
- # cursive (21)
- # datomic (19)
- # defnpodcast (1)
- # emacs (8)
- # events (2)
- # fulcro (71)
- # graalvm (23)
- # jobs-discuss (1)
- # kaocha (5)
- # luminus (5)
- # meander (16)
- # nrepl (32)
- # off-topic (6)
- # pathom (159)
- # pedestal (3)
- # reagent (14)
- # reitit (8)
- # reveal (12)
- # rewrite-clj (9)
- # shadow-cljs (169)
- # spacemacs (16)
- # specter (2)
- # sql (19)
- # tools-deps (36)
- # vim (6)
Hi I would like to know how I can handle an optional param like below
(reitit/router
[["/editor" :editor]
["/editor/:slug" :editor]])
I guess I could have :editor and :editor-slug but is there a way to say slug does not have to exist
@oliver.marks I think your options are {:conflicts nil}
for all routes or {:conflicting true}
for a specific route.
@steven427 thanks I thought would be a better way than that 😕
just felt like there should be a better way would explain why I could not find it in the docs as well
@oliver.marks Oh, sorry. I missed half your question. Yeah, I was actually just doing something similar (sort of the inverse of your problem with :editor
) yesterday because I want to replicate Rails’ resource-oriented named-route lookups. I ended up hacking up an :alias
feature for the path lookup:
https://github.com/pariyatti/kosa/blob/e59bf595663381ab24f31fbbaf1e2f8337bf62a0/src/kosa_crux/routes.clj#L58
https://github.com/pariyatti/kosa/blob/e59bf595663381ab24f31fbbaf1e2f8337bf62a0/src/kosa_crux/views.clj#L15
That way I can do something like (path-for request :show id)
and (path-for request :destroy id)
and they both return the same path: "/images/:id"