Fork me on GitHub
#pedestal
<
2022-04-05
>
kaffein16:04:54

hey people 👋 … quick question regarding interceptors . I am trying to implement one to process a hmac signature to verify incoming requests on one of my webhooks. And even though I have placed this interceptor as the first in my interceptor stack, I can not seem to be able to retrieve the raw json body of the request from there i.e it is already null at that point. It seems that the underlying Inputstream has already been consumed. Also, I have some other stuff in my interceptors chain for e.g body-params but unfortunately I can not re-build the exact same request body as the original raw one for the hash calculation. What am I missing ? Is there a way for me to have this raw initial json body somehow saved in the context maybe ? thanks in adv.

isak16:04:36

@kaffein just call .reset on that inputstream

kaffein16:04:23

oh okay, I will try that out @isak :thumbsup: thanks for the hint

ghadi16:04:20

not always possible, sometimes streams are truly gone

ghadi16:04:34

might want to find/replace the interceptor that is doing the slurping

ghadi16:04:51

and make it slurp and hash, or slurp and leave the original

👍 1
🙏 1
isak16:04:26

It should be possible because I have done the same thing, but yea that might be better

kaffein16:04:20

oh okay @ghadi but I guess it might be some interceptor added implicitly by Pedestal then because I have already placed mine at the top of the chain in the service-map.