Small D Class - New version of the micro-services springcloud + Docker tutorial _6-02 springcloud gateway component zuul

notes 

2, SpringCloud basic use of the gateway component zuul
    Introduction: explain the basic use zuul gateway

    1, adding dependence


    2, start class add comments @EnableZuulProxy
        default integrated circuit breaker @EnableCircuitBreaker

        default access rules  
            http: // gateway: port / service -id / * *

                example:? default / the Order-Service / API / v1 / the Order / the Save user_id = 2 & product_id = 1
                     ? custom / xdclass_order / api / v1 / order / save user_id = 2 & product_id = 1

        custom routing forwarding:
            Zuul:
             routes:
                 the Order -service: / apigateway / **


        environmental isolation configuration:
            demand: do not want to expose the external interface to the default service
                / order-service / api / v1 / order / save

            configurations:
            Zuul: 
                ignored-patterns:
                    - /*-service/api/v1/order/save

 

Start


New Project reply before some data before the analog, for example, 2 seconds delay ProductService which here commented.

New Project






You need to sign up to the registry.

Select Gateway Zuul

chose these two


default dependency when creating the project has come in loaded

configuration file format changed yml

need a name to the application from. spring.a will only prompt, select application.name first one will be able to


specify the address registry

start classes annotated

notes of EnableZuulProxy

 

Start the application

api-gateway is registered to the registry



        default access rules  
            http: // gateway: port / service -id / **

                Example:? default / order-service / api / v1 / order / save user_id = 2 & product_id = 1
                     Custom / xdclass_order / api / v1 / order / save ? user_id = 2 & product_id = 1

this is the address of the service access to the original order

through the gateway access interface service orders. Now is the gateway through Zuul

had direct access productService of


access through the gateway productService

Custom Path Rules



apigateway replaces the order-service

restart the application to test
the default is accessed using the order-service of

replaced apigateway



ignored product-service. Goods and services not provided to the external routing

restart the service
order service is normally accessible

product-service may be original access, access is now less than

ignored: / * - service / **
a * match everything between the two slashes, ** is everything after the match slashes.

Restart the application
 



to goods and services also add to the mix

of goods and services can also access a list of data interfaces to



directly access the product through the port services is not possible through the gateway. Port 8773

Environmental isolation

    Environmental isolation configuration:
            Demand: do not want to expose the external interface to the default service
                / order-service / api / v1 / order / save
actually deployed inside and outside the network isolation is the way





 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11455076.html