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