I just started maintaining a new codebase that uses the juxt/bidi routing library, which I've not used before. In going through the code, the project uses some features which are not fully documented in the juxt/bidi README, so I wrote some demo code to clarify what is going on and the proper syntax to use.
https://github.com/io-tupelo-demo/bidi It is written as a sequence of unit tests, so one can verify that everything is OK by just running `lein test`: ~/io.tupelo.demo/bidi > lein clean ; lein test lein test _bootstrap ------------------------------- Clojure 1.10.1 Java 13 ------------------------------- lein test tst.demo.core Ran 2 tests containing 17 assertions. 0 failures, 0 errors. The demo tests start out simple: (let [route ["/index.html" :index]] (is= (bidi/match-route route "/index.html") {:handler :index}) ; found route (is= (bidi/match-route route "/another.html") nil) ; did not find route (is= "/index.html" (bidi/path-for route :index))) ; find URI for handler but then dive into some lesser-known features like "Guards": ; short version to match GET "/index.html" (let [route ["/index.html" {:get :index}]] (is= (bidi/match-route route "/index.html" :request-method :get) {:handler :index, :request-method :get}) (is= (bidi/match-route route "/index.html" :request-method :put) nil)) ; long version to match GET "/index.html" (let [route ["" { {:request-method :get} {"/index.html" :index} }]] (is= (bidi/match-route route "/index.html" :request-method :get) {:handler :index, :request-method :get}) (is= (bidi/match-route route "/index.html" :request-method :post) nil)) Enjoy! Alan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/CAN67zA3WP4vUK9yCSKghrsU6t0pWL-ArtFzy-LOiwSaGOkpK1Q%40mail.gmail.com.