Spring cloud gateway routing gateway source code analysis 02 01

The core is loaded, the routing function is as follows

After obtaining routing route, then call validateRoute check

Create a type of  org.springframework.cloud.gateway.config.GatewayProperties Bean object, used to load the configuration file RouteDefinition configuration / FilterDefinition

Spring Cloud Gateway Diagram

Look at the routing example sample, as follows

Specify a filter, it is forwarded to the designated post-processing uri

Route construction, divided into synchronous and asynchronous, the parameters are RouteDefinition

Look load RouteDefinition

RouteDefinition, text string initialized by

Similarly initialization PredicateDefinition

Similarly FilterDefinition

Reads the routing configuration from the configuration file

routes Property, routing configuration. By  spring.cloud.gateway.routes Configuration

 

Route memory

That is to update the local data memory map of routes

 

DiscoveryClientRouteDefinitionLocator route discovery, obtaining registration in the registry list of services, generating a corresponding array RouteDefinition.

1. First analytical expression profiles, get includePredicate

The parsed service instance and urlExpr serviceInstance, constructed routeDefinition

3. then parsed profile predicate, is added to the RouteDefinition

4. Continue parses out the configuration file filters, added to the RouteDefinition

5. Finally return RouteDefinition

 

 

Published 386 original articles · won praise 2 · Views 9839

Guess you like

Origin blog.csdn.net/kuaipao19950507/article/details/105255731