Configuration access method in gateway in springcloud

Yml file configuration in gateway

Copy code

spring:
  cloud:
    gateway:
      discovery:
        locator:
         enabled: true
         lowerCaseServiceId: true
      routes:
        - id: feign-client
          uri: lb://feign-client
          predicates:
            - Path=/feign-client2/**
          filters:
            - StripPrefix=2

Copy code

 

Access service in gateway

Port 5000 is the gateway port, port 8762 is the accessed service port

Specific services:

 

1. Access the service through router configuration in the gateway:

http://localhost:5000/feign-client2/aaa/feignUser/hi?name=chrchr8855765757567657324324

Equivalent to  /feign-client2/aaa has been removed by the filters attribute StripPrefix=2, and finally it is equivalent to the following request service

  lb://feign-client/feignUser/hi?name=chrchr8855765757567657324324

 

2. The service can also be accessed through the following serviceId

The service center registered serviceId: is the application name of the accessed service, as shown in the figure above: feign- client
http://gateway address: port/service center registration serviceId/specific url
The specific url is the request url of the accessed service module
http://localhost:5000/feign-client/feignUser/hi?name=chrchr8855765757567657

 

3. You can also directly access specific services and bypass the gateway

http://localhost:8762/feignUser/hi?name=chrchr27777

 

Guess you like

Origin blog.csdn.net/suixinsuoyu12519/article/details/112260889