This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-18
Channels
- # announcements (18)
- # babashka (34)
- # beginners (47)
- # biff (1)
- # calva (99)
- # cider (1)
- # clojure (99)
- # clojure-austin (13)
- # clojure-australia (1)
- # clojure-dev (53)
- # clojure-europe (30)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-spec (7)
- # clojure-uk (1)
- # clojurescript (50)
- # cursive (11)
- # datahike (20)
- # datomic (10)
- # fulcro (7)
- # graalvm (8)
- # gratitude (1)
- # introduce-yourself (7)
- # jackdaw (1)
- # joyride (1)
- # lambdaisland (7)
- # lsp (2)
- # malli (7)
- # nbb (1)
- # off-topic (1)
- # portal (24)
- # re-frame (8)
- # reagent (13)
- # reitit (7)
- # releases (2)
- # remote-jobs (8)
- # rewrite-clj (3)
- # sci (1)
- # scittle (21)
- # shadow-cljs (2)
- # testing (3)
- # tools-deps (22)
- # web-security (19)
Why would this happen? i just updated reitit router version on an older project that had been gathering dust Error: Router contains conflicting route paths: -> /projects/create -> /projects/:my-project-id
ah, it was in the docs: "Normal path-parameters (`:id`) can start anywhere in the path string, but have to end either to slash /
(currently hardcoded) or to an end of path string:"
Hello! Can anyone tell me how to use async handler inside ring/router?
(def app
(ring/ring-handler
(ring/router
[["/plus"
{:get {
:parameters {:query {:x int?
:y int?}}
:responses {200 {:body {:total int?}}}
:handler
(fn [{{{:keys [x y]} :query} :parameters} response raise]
(response {:status 200
:body {:total (+ x y)}}))}}]]
{:data {:coercion reitit.coercion.spec/coercion
:muuntaja m/instance
:middleware [parameters/parameters-middleware
rrc/coerce-request-middleware
muuntaja/format-response-middleware
rrc/coerce-response-middleware]}})))
im not sure what's exactly the problem, but the order of your middlwares might be incorrect, OR that function, which threw the exception, might rely on the presence of other middlewares, which are related to the wrap-format-response
.
here the order, what's working in our code:
reitit.ring.middleware.parameters/parameters-middleware
muuntaja/format-negotiate-middleware
muuntaja/format-response-middleware
:handle-exception
muuntaja/format-request-middleware
reitit.ring.coercion/coerce-exceptions-middleware
reitit.ring.coercion/coerce-request-middleware
and one of the official examples are just using muuntaja/format-middleware
:
https://github.com/metosin/reitit/blob/master/examples/ring-example/src/example/server.clji'd highly recommend cloning the following repos, so u can quickly navigate their sources: 1. https://github.com/metosin/reitit.git 2. https://github.com/ring-clojure/ring.git 3. https://github.com/metosin/muuntaja.git and maybe u can fire up a repl for them, so u can directly run their tests. using the tests, u can easily see how these building blocks behave in some specific, narrow situtation.