This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-05
Channels
- # 100-days-of-code (1)
- # announcements (7)
- # beginners (84)
- # boot (1)
- # cider (22)
- # cljdoc (14)
- # cljs-dev (45)
- # cljsrn (6)
- # clojure (65)
- # clojure-conj (7)
- # clojure-finland (1)
- # clojure-italy (7)
- # clojure-nl (2)
- # clojure-serbia (1)
- # clojure-uk (111)
- # clojurescript (58)
- # cursive (8)
- # datomic (68)
- # duct (1)
- # emacs (33)
- # figwheel (3)
- # figwheel-main (9)
- # fulcro (33)
- # graphql (1)
- # juxt (30)
- # kaocha (4)
- # off-topic (22)
- # pathom (47)
- # pedestal (4)
- # planck (6)
- # re-frame (1)
- # reagent (1)
- # reitit (13)
- # shadow-cljs (49)
- # spacemacs (7)
- # sql (6)
- # tools-deps (60)
I noticed that if you use spec coercion in frontend you need to use spec records or it’s going to fail in production builds. I didn’t understand why.
(Production builds using shadow-cljs, probably optimized using Closure Compiler)
My use case: {:parameters {:path {:foo-id int?}}}
(starts working with spec/int?
)
Hey, I'm having some trouble with getting immutant web serving the ring swagger endpoint created with (reitit.swagger/create-swagger-handler)
. If I run the handler, it works fine, producing a clojure/edn map. But I'm getting:
user=> 2018-11-05 15:49:33,697 [XNIO-4 task-6] ERROR io.undertow.request - UT005071: Undertow request failed HttpServerExchange{ GET /swagger.json request {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8], Connection=[keep-alive], Accept-Language=[en-GB,en-US;q=0.8,en;q=0.5,de;q=0.3], Accept-Encoding=[gzip, deflate], DNT=[1], User-Agent=[Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0], Upgrade-Insecure-Requests=[1], Host=[localhost:3000]} response {Server=[undertow]}}
java.lang.IllegalStateException: Can't coerce body of type class clojure.lang.PersistentArrayMap
In my middleware options I've got reitit.ring.coercion/coerce-response-middleware
, but clearly this isn't the correct middleware to convert to JSON. Any clues for where I should be looking?err, probably more relevant is the following middleware I also have enabled:
muuntaja/format-negotiate-middleware
muuntaja/format-response-middleware
muuntaja/format-request-middleware
@hannu.hartikainen if you can do a minimalistic repro, I investigate. the data-specs get compiled into Spec Records, but if that happens at runtime, it could be that the names are shortened and the type inferrer fails.
@socksy could be that the middleware stack is not in right order, here’s a working chain: https://github.com/metosin/reitit/blob/master/examples/ring-swagger/src/example/server.clj#L65-L80
but if you have order [format-negotiate-middleware format-response-middleware format-request-middleware]
it should be right. Muuntaja doesn’t encode the response body if there is already a Content-Type
header is set, by some 3rd party middleware.
from the upcoming middleware logger, should help to see what mws are doing (or not).
Thanks for the reply, they were indeed that order. I ended up removing everything and taking the middleware from the luminus template, which I can document when I'm back at my computer tomorrow. Middleware logger sounds like a great thing
I've switched my project over to using interceptors and was wondering if there's anything already made that can help with debugging - re-frame has a couple projects (https://github.com/flexsurfer/re-frisk and https://github.com/Day8/re-frame-10x) that I've used to help investigate my interceptors and it's been really useful.