Doubt about layers needed in a simple Gateway made in STS

Asked

Viewed 46 times

0

inserir a descrição da imagem aqui

I made a web service json/Rest that plays the role of a gateway, the client sends the request to an endpoint, but the gateway replicates the request for various services. In it, I just pass the request and join the answer when returning. My question is: I need to put in this gateway all the layers that already exist in the services?

Thanks in advance.

  • I’m not sure why you want to put services in a gateway, which is basically responsible for directing requests only. All your gateway needs is the microservice address to where it needs to direct the request.

  • Okay! So you don’t have to put the layers out, just redirect it and that’s it, right? By the way of the question: the customer does not want to access multiple endponts to receive similar information, requested only one place to collect the information, as the origins were different, the companies involved each made their own service and then unified everything as gateway. Answers the question for me to point out as a solution ;-) :-)

1 answer

1


TL;DR

No, do not place business objects inside a gateway. Keep your coupling as weak as possible.


Explanation

A gateway should not know the core business.

Therefore, no, you should not insert business objects into the gateway layer. This helps preserve the low (or near zero) coupling. Thus, the gateway plays only the simpleton role of a 'passthrough''.

Of course, there are gateways and gateways. Nowadays the Gateways API does much more than that. They are able to do security and, in many, even orchestration and enrichment of messages - whether this is right or wrong does not come into the topic, but my opinion is that the gateway should never be used to make orchestrations and enrichments, it should only make a layer of security and routing to the target back-end.

If you are using Spring, it would be interesting to take a look at the Spring Cloud stack. There is the Zuul API Gateway. It would play this role that you implemented absolutely well and has an immense ease of configuration.

It’s a Java project like any other, with libraries imported through Maven or Gradle, but you just set it up using a YAML file and you’re done! Your gateway is working

Browser other questions tagged

You are not signed in. Login or sign up in order to post.