Fork me on GitHub
#yada
<
2018-06-22
>
nha08:06:26

yes I was worried about the order. I’ll double check my code, you are right about the sig vs secret

nha08:06:07

hm it looks like I was confusing those only in my sample code above 😕

nha09:06:50

It is actually

(println (hmac
                 ba
                 gh-hook-secret))

nha09:06:09

When I do (String. ba) I get “POST /gh-hook HTT” -> doesn’t look like I have the body in that buffer

nha09:06:49

So I guess the question is still, how do I get bytes or the string representing the body in yada?

dominicm09:06:18

I thought it was in the ctx under :body, maybe in :req

malcolmsparks09:06:44

Have a look at other implementations of process-request-body

👋 4
malcolmsparks09:06:27

I'm in a cab in Paris. @dominicm is in the same cab as me 😊

🚕 8
nha09:06:51

ah I was looking at the wrong multimethod it seems (`yada.body/to-body` and render-map render-seq). Will have a look at yada.request-body/process-request-body thanks 🙂

nha10:06:34

looks like this works 😄

(defmethod yada.request-body/process-request-body :raw ;; TODO better naming
  [ctx body-stream media-type & args]
  (let [body-string (bs/to-string body-stream)]
    (assoc-in ctx [:request :body-string] body-string)))

nha11:06:57

the above consumes the [:request :body] - not a big deal, I know it is JSON and can parse it. It would be nice to let yada handle it the “normal”, parse it, validate it etc. Is there a way to recreate the original body-stream or pass something that the rest of the yada interceptor chain would understand there?

nha11:06:27

(probably a manifold question actually - copy a BufferedStream. Not a big deal either way)

nha11:06:13

Thanks for the help everyone 😄