Fork me on GitHub

in bidi, how can I combine to route descriptions like the one below:

(defn handler [sys]
  ["/" {"subscriptions" {:post (fn [req] {:status 200 :body "create-sub-handler"})}
        ["subscriptions/" :id] {:get (fn [req] {:status 200 :body "get-sub-handler"})
                                :delete (fn [req] {:status 200 :body "delete-sub-handler"})}}])
(defn handler' [sys]
  ["/" {"customers" {:post (fn [req] {:status 200 :body "create-sub-handler"})}
        ["customers/" :id] {:get (fn [req] {:status 200 :body "get-sub-handler"})
                                :delete (fn [req] {:status 200 :body "delete-sub-handler"})}}])


I guess the simplest way is to just strip the "/" stuff and do something like ["/" (merge (handler {}) (handler' {}))]


hm but now I'm stuck trying to figure out how to add a catch all route:

(bidi/match-route [["/" {"subscriptions"        {:post (fn [req] (prn sys) {:status 200 :body "create-sub-handler"})}
                         ["subscriptions/" :id] {:get (fn [req] (prn sys) {:status 200 :body "get-sub-handler"})
                                                 :delete (fn [req] (prn sys) {:status 200 :body "delete-sub-handler"})}}]
                   [true #(rres/not-found "Not found")]]
This throws. I tried a few variations of this but none worked.. 😝


@martinklepsch: I don't know if it can help, but this is something similar I am doing:

"admin" {"" (fn [_] (ring/redirect "/admin/login.html"))
                 "/" (fn [_] (ring/redirect "/admin/login.html"))
                 true spa-response}


@richiardiandrea: this brought me on the right track I think, thanks!


I really wish there would be better errors for stuff like this: java.lang.IllegalArgumentException: No implementation of method: :segment-regex-group of protocol: #'bidi.bidi/PatternSegment found for class: clojure.lang.PersistentArrayMap Fighting a weird error that only occurs when using the routing table with make-handler...