This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-16
Channels
- # babashka (48)
- # beginners (44)
- # biff (3)
- # calva (1)
- # cider (42)
- # clj-kondo (8)
- # clojure (93)
- # clojure-australia (2)
- # clojure-europe (3)
- # clojure-taiwan (1)
- # clojurescript (10)
- # conjure (4)
- # deps-new (5)
- # joker (9)
- # lsp (12)
- # membrane (16)
- # minecraft (12)
- # missionary (4)
- # mount (3)
- # off-topic (60)
- # reitit (9)
- # releases (13)
- # ring-swagger (1)
- # shadow-cljs (18)
- # sql (67)
- # tools-deps (2)
Is it possible using Reitit to route to different handlers based on the "Accept"
header field in a request?
Do you want to do some complex routing based on it or just dispatch to different handlers per content type?
dispatch to different handlers per "Accept" type
In that case I'd create a multimethod which dispatches in it as the handler. Reitit only routes based on path afaik
you can also add :accept
key to route data, create a ring-router out of the routes, ask the flattened route tree, group by :accept
, and create separate subrouter out of each. Then create a ring-handler that looks for accept and forwards to the correct sub-router. E.g. one router per defined :accept
.
if you use middleware compilation, the perf penalty is one hash-lookup. Unless you use regexs
Thanks. I think I will choose the middleware approach in my use case.