Http快速开始

    请参考运维部署的内容,选择一种方式启动shenyu-admin。比如,通过 启动Apache ShenYu后台管理系统。

    启动成功后,需要在基础配置->插件管理中,把divide 插件设置为开启。在Apache ShenYu网关中,Http请求是由divide插件进行处理。

    启动网关,如果是通过源码的方式,直接运行shenyu-bootstrap中的ShenyuBootstrapApplication

    下载

    运行org.apache.shenyu.examples.http.ShenyuTestHttpApplicationmain方法启动项目。

    2.4.3开始,用户可以不配置shenyu.client.http.props.port

    成功启动会有如下日志:

    1. 2021-02-10 00:57:07.561 INFO 3700 --- [pool-1-thread-1] o.d.s.client.common.utils.RegisterUtils : http client register success: {"appName":"http","context":"/http","path":"/http/test/**","pathDesc":"","rpcType":"http","host":"192.168.50.13","port":8188,"ruleName":"/http/test/**","enabled":true,"registerMetaData":false}
    2. 2021-02-10 00:57:07.577 INFO 3700 --- [pool-1-thread-1] o.d.s.client.common.utils.RegisterUtils : http client register success: {"appName":"http","context":"/http","path":"/http/order/save","pathDesc":"Save order","rpcType":"http","host":"192.168.50.13","port":8188,"ruleName":"/http/order/save","enabled":true,"registerMetaData":false}
    3. 2021-02-10 00:57:07.596 INFO 3700 --- [pool-1-thread-1] o.d.s.client.common.utils.RegisterUtils : http client register success: {"appName":"http","context":"/http","path":"/http/order/findById","pathDesc":"Find by id","rpcType":"http","host":"192.168.50.13","port":8188,"ruleName":"/http/order/findById","enabled":true,"registerMetaData":false}
    4. 2021-02-10 00:57:07.606 INFO 3700 --- [pool-1-thread-1] o.d.s.client.common.utils.RegisterUtils : http client register success: {"appName":"http","context":"/http","path":"/http/order/path/**","pathDesc":"","rpcType":"http","host":"192.168.50.13","port":8188,"ruleName":"/http/order/path/**","enabled":true,"registerMetaData":false}
    5. 2021-02-10 00:57:08.026 INFO 3700 --- [ main] o.d.s.e.http.ShenyuTestHttpApplication : Started ShenyuTestHttpApplication in 2.555 seconds (JVM running for 3.411)

    shenyu-examples-http项目成功启动之后会自动把加 注解的接口方法注册到网关。

    Http快速开始 - 图2

    下面使用postman模拟http的方式来请求你的http服务:

    下面使用IDEA HTTP Client Plugin模拟http的方式来请求你的http服务[本地访问,不使用shenyu代理]:

    Http快速开始 - 图4