This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-01
Channels
- # aws (37)
- # babashka (7)
- # babashka-sci-dev (2)
- # beginners (75)
- # biff (7)
- # calva (85)
- # cider (9)
- # clj-kondo (26)
- # clj-yaml (1)
- # clojure (45)
- # clojure-europe (4)
- # clojure-norway (1)
- # clojure-spec (3)
- # clojure-uk (2)
- # clojurescript (3)
- # core-typed (2)
- # cursive (12)
- # fulcro (3)
- # humbleui (5)
- # jobs (8)
- # malli (1)
- # meander (3)
- # membrane (1)
- # portal (50)
- # squint (15)
- # vim (1)
And for anyone who wants to read the implementation: https://github.com/jacobobryant/biff/blob/master/src/com/biffweb/impl/queues.clj
Next week: planning to replace the task
script with bb tasks
, and a handful of other small-ish improvements (e.g. submit-tx
is going to become a bit fancier). After that I'll start on a medium-sized create-your-own-forum-thing tutorial for the docs, the project which my latest clj together funding is for.
Does anyone know if it's possible to match routes with different domains, instead of just paths? I have a subdomain that I would like to serve a couple of specific routes from my main Biff server, I did not find anything for this in Reitit yet
If nothing else, you could always make two separate reitit routers/handlers and then put some middleware/another handler on top that picks which one to use based on the domain. e.g. in your main clj file, replace this bit:
(def routes [["" {:middleware [anti-forgery/wrap-anti-forgery
biff/wrap-anti-forgery-websockets
biff/wrap-render-rum]}
(keep :routes features)]
(keep :api-routes features)])
(def handler (-> (biff/reitit-handler {:routes routes})
(biff/wrap-inner-defaults {})))
With this:
(def routes [["" {:middleware [anti-forgery/wrap-anti-forgery
biff/wrap-anti-forgery-websockets
biff/wrap-render-rum]}
(keep :routes features)]
(keep :api-routes features)])
(def custom-domain-routes [["" {:middleware [anti-forgery/wrap-anti-forgery
biff/wrap-anti-forgery-websockets
biff/wrap-render-rum]}
(keep :custom-domain-routes features)]
(keep :custom-domain-api-routes features)])
(defn dispatch-on-domain [handler1 handler2]
(fn [request]
((if ...
handler1
handler2)
request)))
(def handler (-> (dispatch-on-domain (biff/reitit-handler {:routes routes})
(biff/reitit-handler {:routes custom-domain-routes}))
(biff/wrap-inner-defaults {})))
and then put all the subdomain routes under :custom-domain-routes
and/or :custom-domain-api-routes
in your feature maps (maybe rename those to be less verbose).alternatively maybe you could add middleware to rewrite the path, e.g. if you get a request to /foo/
on the subdomain, have the middleware change it to /subdomain/foo/
.
(you'll also need to make sure the letsencrypt cert works for the subdomain if you haven't already--should be pretty easy though, I think just re-run certbot --nginx
on the server)