reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
Yehonathan Sharvit 2021-07-05T10:13:16.120Z

A reitit newbie question: why is it important that routes have names?

2021-07-05T10:17:45.120200Z

My 2 cents: When you want to redirect to a different route, you use its name instead of copy/pasting its url.

☝️ 1
juhoteperi 2021-07-05T13:01:02.120700Z

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.

juhoteperi 2021-07-05T13:01:23.120900Z

So I don't think it necessarily is "important", it is just useful in some cases.

Alexander Moskvichev 2021-07-05T19:31:18.129300Z

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

lsenjov 2021-07-05T22:29:26.129600Z

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”