The spirng clound service gateway solves the problem of calling microservices from static web pages


In the microservice architecture, back-end services are often not directly open to the caller, but routed to the corresponding service through an API gateway according to the requested url. When the API gateway is added, a wall is created between the third-party caller and the service provider. This wall communicates directly with the caller for permission control, and then distributes requests to the background server in a balanced manner.


1.pom file configuration

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>

2.yml



3. Write a filter class You can define a filter, and you need to integrate the filter class provided by zuul for verification and interception.


4. Configure in the startup class of spring boot

All requests starting with /sso are routed to the microservice specified by serverid


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325901808&siteId=291194637