This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-10
Channels
- # announcements (4)
- # babashka (40)
- # beginners (39)
- # calva (16)
- # cljdoc (1)
- # cljs-dev (8)
- # clojure (72)
- # clojure-europe (10)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-spec (9)
- # clojure-uk (12)
- # clojurescript (16)
- # community-development (15)
- # conjure (5)
- # cursive (5)
- # datomic (26)
- # eastwood (1)
- # emacs (7)
- # events (1)
- # figwheel-main (15)
- # fulcro (27)
- # graphql (7)
- # gratitude (4)
- # introduce-yourself (1)
- # malli (4)
- # meander (4)
- # off-topic (2)
- # other-languages (13)
- # polylith (7)
- # reagent (5)
- # reitit (5)
- # shadow-cljs (27)
- # spacemacs (4)
- # sql (3)
- # tools-deps (6)
- # xtdb (13)
Hello, I am developing against Stripe’s API. To verify the signature (put into the request header by the stripe servers) I need to call Webhook.constructEvent(payload, signature, webhook_access_key)
. payload
is the raw body of the request, signature
is read from the request header, webhook_access_key
comes from the API Dashboard of stripe.
Now the problem is, that the raw-body of a request is an InputStream, which can only be read once. And the body is read by a middleware (actually I don’t really know which one), which is quite fine (I need the processed information from the request-body), but then I can’t access the raw-body. Do you have any ideas on how I can access the raw-body? Is there a configuration option for muuntaja/format-middleware (I think this one parses the body)? I am using these built-in middlewares: swagger/swagger-feature, parameters/parameters-middleware, muuntaja/format-middleware, coercion/coerce-response-middleware, coercion/coerce-request-middleware, multipart/multipart-middleware
Thanks!
Hey! I faced this problem as well and my solution was that I have a hooks endpoint for stripe which only uses the format-response-middleware because, as you said, you need to be the one who reads the req-body stream. Having said this, note that i’m not actually sure if the reitit team has another way to handle this. I came to this solution after reading 70% of reitit source. Looking back, you can totally add other middleware to get all the other functionality after you handle the raw req-body.
Thanks for your thoughts. One of mine was to read the raw body in a first place, then have it persisted as a string in a :body
oder :raw-body
field in the request, But it seems a bit weird to read the raw-string before another middleware does so. Thought about it that there must be a smarter way 😄
Hi. I’d like to know how compile
works. For example, there is a
{:compile coercion/compile-request-coercers}))
in https://cljdoc.org/d/metosin/reitit/0.5.15/doc/coercion/coercion-explained#:~:text=id%20s/Int%7D%7D%7D%5D-,%7B%3Acompile%20coercion/compile%2Drequest%2Dcoercers%7D)),-Routing%20again%3A
Also, there is a default
:compile compile-result
in https://github.com/metosin/reitit/blob/5973bc0f26673d26657d783116f987d015102b03/modules/reitit-ring/src/reitit/ring.cljc#L100
What are they?