This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-05
Channels
- # aws (12)
- # babashka (30)
- # beginners (294)
- # calva (98)
- # clj-on-windows (3)
- # clojure (48)
- # clojure-europe (31)
- # clojure-italy (8)
- # clojure-nl (2)
- # clojure-uk (11)
- # clojurescript (58)
- # conjure (1)
- # events (1)
- # fulcro (35)
- # graalvm-mobile (2)
- # jobs (8)
- # lsp (11)
- # malli (25)
- # off-topic (33)
- # pathom (24)
- # pedestal (1)
- # polylith (15)
- # re-frame (7)
- # reitit (10)
- # releases (8)
- # remote-jobs (2)
- # sci (3)
- # shadow-cljs (79)
- # spacemacs (10)
- # sql (17)
- # tools-deps (17)
- # vim (4)
- # xtdb (11)
A reitit newbie question: why is it important that routes have names?
My 2 cents: When you want to redirect to a different route, you use its name instead of copy/pasting its url.
Why do you think it is important that routes have names? In frontend it is useful when generating hrefs from route tree, in backend it isn't often that needed. In reitit either the handler fn or name are just part of match data, and reitit-core doesn't care about either. The ring adapter uses handler fn, reitit match-by-name (from core or frontend) uses the name.
So I don't think it necessarily is "important", it is just useful in some cases.
If you move the path of your route around, you don’t want to be refactoring the paths in every place that calls it. Far less fragile to say “give me the href of this route with these args”
Thank you guys for your insights @U8MJBRSR5 @U061V0GG2 and @U24QP2D4J
Is it possible to define the routing table in terms of names only and to provide a separate map of names to handlers?
I mean, you could walk your routing table and add in the handlers from an external map?
You could add a bottom level middleware that takes the route and calls the handler yourself? It smells really bad though
Hi. I'm trying to write a spec for this route /api/debug?level=1&page[p]=10
Here is route ["/debug" {:get {:parameters {:query {:level int? (keyword "page[p]") int?}}
:handler (fn [{{:keys [query]} :parameters}] (response/ok {:query query}))}}]
I'm using reitit.coercion.spec
Works perfect, but I need the parameter "page[p]"
to be optional.
Edit: trying (s/def (keyword ":" "page[p]") int?)
...:opt-un [(keyword ":" "page[p]")]
but it didn't work. An error message is "Assert failed: k must be namespaced keyword or resolvable symbol
(c/and (ident? k) (namespace k))"