This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-24
Channels
- # announcements (1)
- # aws (2)
- # beginners (147)
- # boot (19)
- # cider (57)
- # clara (52)
- # cljdoc (18)
- # cljs-dev (14)
- # cljsrn (4)
- # clojure (176)
- # clojure-conj (9)
- # clojure-dev (9)
- # clojure-germany (2)
- # clojure-italy (4)
- # clojure-spec (13)
- # clojure-uk (56)
- # clojurescript (72)
- # code-reviews (11)
- # cursive (17)
- # data-science (1)
- # datomic (52)
- # duct (26)
- # emacs (6)
- # events (9)
- # figwheel (1)
- # figwheel-main (21)
- # fulcro (132)
- # funcool (1)
- # graphql (3)
- # jobs-discuss (42)
- # leiningen (3)
- # luminus (45)
- # mount (10)
- # off-topic (2)
- # re-frame (17)
- # reagent (12)
- # reitit (20)
- # ring-swagger (7)
- # rum (3)
- # shadow-cljs (256)
- # slack-help (15)
- # sql (7)
- # tools-deps (50)
- # uncomplicate (1)
- # yada (9)
Is there an easy way to match a path both with and without a trailing slash (e.g. /products
and /products/
)? It would be nice in frontend, as users tend to edit urls manually time to time.
@hannu.hartikainen currently, nothing built-in. But there’s a issue for it: https://github.com/metosin/reitit/issues/92
ok, I might see what implementing it would take if I ever have a bit of free time
yeah, I was thinking that I could just have a middleware that strips trailing slashes or something
but can there be middleware without ring 🙂
but a helper that takes a router and strips all the trailing spaces would be easy to do.
yeah. I’m starting to remember now that I delve deeper into my own code.
I think this is resolved elegantly with many other routing libs (but not in Clojure when I checked)…
It’s bit like the ignore-case string lookup: create an index with all lower-cases and lower-case the query too.
https://github.com/julienschmidt/httprouter > Stop caring about trailing slashes: Choose the URL style you like, the router automatically redirects the client if a trailing slash is missing or if there is one extra. Of course it only does so, if the new path has a handler. If you don’t like it, you can turn off this behavior.
hihi, noob question probably: how do I wrap-anti-forgery to certain routes properly? I've tried middleware/registry, but that didn't work. Or should I just wrap-anti-forgery (and wrap-session) on the entire reitit-created handler?
@shaolang welcome! there is guide how to set middleware to certain routes only: https://cljdoc.org/d/metosin/reitit/0.2.4/doc/ring/ring-router#middleware
if your mw doesn’t take parameters, you can just say :middleware [wrap-anti-forgery]
to any of the route data. valid scopes are: router, partial path, path/endpoint, method.
I'm moving some code over from a Compojure site and I'm having trouble downloading a generated file from a function that takes a while to return. I'm running into an issue where the reitit version is firing off my function, then returning a blank file instead of waiting for it to return. Is there anything reitit-specific that I should be looking at to figure this out?