This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-06
Channels
- # announcements (1)
- # beginners (147)
- # boot (9)
- # calva (28)
- # cider (3)
- # circleci (18)
- # cljdoc (54)
- # cljs-dev (55)
- # cljsrn (22)
- # clojure (179)
- # clojure-canada (9)
- # clojure-dev (74)
- # clojure-europe (1)
- # clojure-italy (15)
- # clojure-nl (7)
- # clojure-spec (30)
- # clojure-uk (55)
- # clojurescript (65)
- # core-async (15)
- # cursive (12)
- # datomic (16)
- # events (4)
- # fulcro (25)
- # graalvm (3)
- # joker (2)
- # kaocha (15)
- # keechma (94)
- # off-topic (12)
- # qlkit (2)
- # re-frame (15)
- # reagent (11)
- # reitit (29)
- # remote-jobs (15)
- # rewrite-clj (16)
- # shadow-cljs (73)
- # spacemacs (151)
- # sql (3)
- # tools-deps (11)
- # unrepl (19)
- # vim (35)
Having some trouble getting multipart coercion working right. Here’s my route, based on looking at the docs and examples:
["/drop" {:coercion rcs/coercion
:name :email-drop
:parameters {:multipart {:file multipart/temp-file-part}}
:middleware [middleware/wrap-internal-error
middleware/wrap-formats
middleware/wrap-base
multipart/multipart-middleware
]
:post {:summary "Mail drop endpoint for api."
:handler #'maildrop/post-attachments}}]
when I post a multipart form to this endpoint, I get back this:
{:body "[:spec \"(spec-tools.core/spec {:spec (clojure.spec.alpha/keys :req-un [:spec$45582/file]), :type :map, :leaf? false})\"][:problems []][:type :reitit.coercion/request-coercion][:coercion :spec][:value {}][:in [:request :multipart-params]]",
:status 400,
:headers {:Content-Length "0", :Server "http-kit", :Date "Thu, 06 Jun 2019 13:35:18 GMT"}}
I’m not sure how to interpret that. Am I missing a config step somewhere?
(The multipart
ns in my source code is reitit.ring.middleware.multipart
)
@manutter51 you could debug using the middleware debugger to see if something is consuming the multiparts already, see https://cljdoc.org/d/metosin/reitit/0.3.7/doc/ring/default-middleware#inspecting-middleware-chain
The examples app have the multipart & swagger-ui to test that it works (with the right mw stack).
Ah, that’s helpful, Just understanding what the error means gives me a big hint. Thanks much!
Howdy! Loving my early experiences with Reitit so far. Any recommendations for how I might generate swagger.json
as part of a lein task? I’m trying to prototype a little swagger codegen script, and I’d rather not have to boot my app as part of the process.
Answered my own question. For future reference, you can just build a lein task around something like this:
(->> (app {:request-method :get :uri "/api/swagger.json"})
:body
(m/decode "application/json"))
Hmm, no, it looks like nothing’s reading the body, it seems to exit the middleware with the body unread. I did find that there was already a multipart middleware handler in the top-level router stuff, so I got rid of the duplicate. Moving the multipart middleware higher in the list gets me a spec error containing :pred (clojure.core/fn [%] (clojure.core/contains? % :file))
, which makes me think something somewhere is expecting a map with a :file
key in it?
I am trying to understand how the following is a path conflict:
[["/bulk/:bulk-id"]
["/:version/status"]]
as I would expect “/bulk/2” and “/2/status” to be easy to distinguish. Any suggestion? Thanks!@kingcode "/bulk/status"
would match both routes. Disabling the conflict resolution makes it match in the order they are defined.
@manutter51 your parameter definitions say that there is one part called :file
and it's a file.
@ikitommi Ok, thanks — I wondered about that, I’m “cargo-culting” that bit from the examples and wasn’t sure what :file
meant in that context
the examples have swagger-ui, which sends the parts correctly, check example how to send parts?
I’m trying to map the Mailgun API to reitit so I can upload email attachments (https://documentation.mailgun.com/en/latest/user_manual.html#routes)
Can’t quite figure out the ???
part for :parameters {:multipart { ??? }}
Hmm, I bet that needs to be a complete list of all the multipart params I’m expecting
Ok, I think I’m over the hurdle, conceptually, just gotta get it all spec’ed out and working
Thanks again
Hi! my first day with reitit-ring. Newbie question: can I set routes with the same path but different HTTP methods:
@aarkerio welcome! I would recommend you read the ring-guide (https://cljdoc.org/d/metosin/reitit/0.3.7/doc/ring). But, here’s how to do it: ["/login" {:get cont-users/login-page, :post cont-users/post-login}]
.