This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-13
Channels
- # 100-days-of-code (5)
- # adventofcode (1)
- # announcements (8)
- # beginners (148)
- # boot (17)
- # calva (26)
- # cider (17)
- # cljdoc (2)
- # cljs-dev (55)
- # cljsjs (2)
- # clojure (198)
- # clojure-dev (11)
- # clojure-finland (1)
- # clojure-italy (23)
- # clojure-nl (6)
- # clojure-spec (44)
- # clojure-uk (148)
- # clojurescript (27)
- # clojutre (20)
- # core-logic (21)
- # cursive (12)
- # datascript (10)
- # datomic (33)
- # emacs (11)
- # figwheel-main (49)
- # fulcro (19)
- # graphql (2)
- # off-topic (48)
- # onyx (2)
- # other-languages (53)
- # pedestal (3)
- # reagent (75)
- # reitit (17)
- # rum (1)
- # slack-help (2)
- # specter (2)
- # sql (3)
- # tools-deps (24)
- # unrepl (4)
- # yada (1)
@ikitommi So i’m running into problems with reitit and ring-cors. Turns out, when I include wrap-cors
in a middleware field, preflight requests fail unless :options
is set as a field on an endpoint.
Wrapping wrap-cors
around ring-handler
works, but it ends up clobbering the metadata, which means I have to do the meta
and with-meta
dance to get around it.
Is there a more idiomatic way to go about this?
@levitanong could you write an issue out of that with a failing sample? Currently on #clojutre, could check out later.
@ikitommi will do!
@grierson good question. For now, the reitit.ring/create-default-handler
knows wether the nil
originated from route miss, method-missing or a handler returning nil
.
you can also investigate the created route tree to see which paths handle what methods
I used some custom middleware to trace things
(defn wrap-checkpoint
"Dev tool to print diagnostic msgs as request flows thru middleware."
[handler msg & [after]]
(let [log-fn #(log/trace %) ] ; Move to config
(fn [req]
(log-fn msg)
;;(try
(let [result (handler req)]
(when after
(log-fn {:after after}))
result)
;; (catch Exception e
;; (clojure.pprint/pprint {:exception e :msg msg :after after})
;; (throw e)))
)))
there is an example on https://metosin.github.io/reitit/ring/ring.html
there is also an option to modify the middleware chain, e.g. interleave a debugging mw between every mw (if the reason would be ill-behaving mw. Guide: https://metosin.github.io/reitit/ring/transforming_middleware_chain.html
Is that recent? I don’t remember seeing that when I wrote my custom middleware (which was a while ago tbh)
plan is to build a kick-ass dev-tool, which would expose all the routing artefacts via a web-tool. Will allow a request to be inspected or modified step-by-step. Kinda like a routing debugger/doc tool
nice, looking forward to that!
I might have just missed it, or else I wanted the functionality to put specific “before” and “after” messages around each piece of middleware.
can’t remember now
Why does ring.middleware.file/wrap-file
not work inside :data :middleware
in ring/ring-handler
? It only works for me if I put it outside of ring-handler
. Demo - https://gist.github.com/apeckham/d70e08e4dcc54dfd1531b94f1fbc267e