0

In my project, I am exposing a rest service which will forward the request to some other backend as it is (in this case my system works just like a proxy).

Backend also have the rest interface exposed and to call it I can use spring rest template (but I am open to suggestions and other frameworks).

My question is that how could I achieve this if I don't want to map the json to pojo or vice-versa and I just want to forward the exactly same request to backend and exactly same response to client without any transformations?

(I am open to suggestions for change of frameworks if this is not possible with spring)

Popeye
  • 1,548
  • 3
  • 25
  • 39
  • See if this helps you https://spring.io/guides/gs/consuming-rest/ – Jabir Jan 04 '18 at 13:00
  • The example maps json to object :( Quote quote = restTemplate.getForObject – Popeye Jan 04 '18 at 13:08
  • You don't have to use pojo serialization at all. In my project I've written a JSON validator where you can Handle the incoming request JSON as a general String and write a Method where a JSON schema you define is compared with the incoming Object. Of cousre it's a bit more work to do but in your case you have to validate the Json only once and for every forward you can just send the Json in the Body and handle it as such. So there is no need for mirroring Objects between services. This gives you also the flexibility to use the Object between Services written in different languges – FishingIsLife Nov 01 '19 at 10:15
  • https://mvnrepository.com/artifact/com.github.java-json-tools/json-schema-validator/2.2.8 as an example – FishingIsLife Nov 01 '19 at 10:19

0 Answers0