0

I am able to get plain json request by using interceptor in spring rest controller for logging purpose. But once the json is read from inputstream of my httpservletrequest, it become null in my controller layer. Is there a way to Set back the json in input stream of my httpservletrequest in the interceptor laye? TIA.

user6543599
  • 541
  • 2
  • 8
  • 18

1 Answers1

0

Yes, it's because how the spring handle HttpServletRequest. (once read inputstream from client inputstream will be empty.)

So, there can be a solution below.

  1. Read bytes from inputstream (from client side)
  2. Use the bytes data. (parse to JSON and use as your business logic)
  3. Make inputstream from the bytes (to pass to reverse proxy)
  4. Pass this to back-end.
Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80