This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-08
Channels
- # announcements (10)
- # babashka (4)
- # beginners (98)
- # cider (47)
- # clara (6)
- # clj-kondo (16)
- # clojure (54)
- # clojure-australia (3)
- # clojure-berlin (3)
- # clojure-czech (2)
- # clojure-europe (77)
- # clojure-nl (4)
- # clojure-uk (12)
- # clojuredesign-podcast (6)
- # clojurescript (10)
- # conjure (56)
- # cursive (3)
- # data-science (6)
- # datascript (8)
- # datomic (213)
- # depstar (5)
- # events (1)
- # figwheel-main (2)
- # fulcro (23)
- # graalvm (2)
- # jobs (3)
- # london-clojurians (1)
- # malli (30)
- # meander (15)
- # midje (1)
- # mount (5)
- # off-topic (18)
- # re-frame (4)
- # reitit (15)
- # remote-jobs (1)
- # shadow-cljs (23)
- # spacemacs (10)
- # specter (1)
- # tools-deps (88)
- # vim (16)
- # xtdb (1)
What is the least-disgusting / most-compatible way to resolve route conflicts to keep URLs structured as Rails does?
["/pali_word_card" {:name ::pali-word-create
:post (wrap-spec-validation :entity/pali-word-request pali-word-handler/create)}]
;; conflicting:-
["/pali_word_card/new" {:name ::pali-word-new
:get pali-word-handler/new}]
["/pali_word_card/:id" {:name ::pali-word-show
:get pali-word-handler/show}]
:conflicts nil
is a sledgehammer and even :conflicting true
feels... heavy. Is there any other way around this?:conflicts nil
is good and could have been the default option. If you have a route table with 100 routes and add a pair of conflicting routes, e.g. /pali_word_card/new
& /pali_word_card/:id
, those two will be isolated into a separate linear-router, all others will be served with best possible algo.
the perf penalty for non-conflicting routes in that is one extra function call, few nanos in practise.
oh, wait... conflict errors are to enable perf, not precision?
(i was worried that :conflicts nil
might cause errors)
it’s precision in case you have a masked route, e.g.
[["/kikka/:id"]
["/kikka/kukka"]]
-> the second one is effective unreachable.rad. so as long as routes are in order, everything's golden?
the conflict resolver could be smarter and know that
[["/kikka/kikka"]
["/kikka/:id"]]
actually is not conflicting as the fixed term(s) comes first. PR welcome 🙂🙂 i'll try to familiarize myself with all the parts of reitit before I try opening a PR. making a note, though.
hi! i’m getting 404 for urls like this: /foo/../bar
but /bar
respond with 200
looks like reitit is not supporting single- and double-dot path segments, isn’t it?
@delaguardo no, it’s not. you could have something (middleware etc) rewrite the url before it enters routing.
this is how I solve it. wouldn’t it be too much impudence to ask for such a feature included (behind an option) in core router?
@ikitommi fwiw, after 5 years away from clojure (and programming in general), it's nice to come back to the scene and find something like reitit
. just replaced all my routing in the new app/service we're building and it honestly worked exactly as i've always wanted routing to work in clojure. thank you!