Fork me on GitHub
#yada
<
2018-11-14
>
genRaiy11:11:06

on body coercion … it seems like it would in the Clojure spirit to retain the original body but I can’t see a :original-body key or some such

genRaiy12:11:08

we can add an interceptor to achieve this but just wondered

stijn12:11:19

isn't that (get-in ctx [:request :body])? but what is the original body? it's a stream, and how it's handled depends on the content-type

stijn12:11:08

@raymcdermott on updating the bidi tree, we use postwalk to update each yada resource in (part of) the tree

stijn12:11:11

(defn update-resources [routes f & args]
  (postwalk
    (fn [x]
      (if (instance? Resource x)
        (resource (apply f x args))
        x))
    routes))

stijn12:11:15

f has to return a thing that's coerceable (or how do you even spell that 🙂 ) to a resource

genRaiy13:11:51

I mean that in some cases you want the body uncoerced by the content-type

genRaiy13:11:28

in our case we want the raw body string so that we can check the signature against the string rather than the coerced EDN / JSON / etc… but still want the mime type so that we know how to process it

genRaiy13:11:18

fwiw the yada manual signals that some ambiguity exists on whether to perform coercion

malcolmsparks13:11:15

I think you can set the :body in the :response to avoid coercion

malcolmsparks13:11:32

I'm afk otherwise I'd check the c9de

genRaiy13:11:06

yes, that makes sense though in this case I mean on the way in rather than on the way out

genRaiy13:11:05

with the interceptor approach we have to read the raw stream which is a bit ugly but works

genRaiy13:11:49

and then we place a :raw-body key on the :request

nha15:11:53

I remember having a discussion in this channel quite some time ago about raw-something. In the end I think I went with a custom interceptor-chain