Loading

Eureka Server的REST端点

Eureka Server的REST端点

Windows下面可以安装Curl;

使用more命令可以显示xml内容;

D:\Java\IdeaProjects>more rest-api-test.xml|curl -v -X POST -H "Content-type:app
lication/xml" -d @- http://localhost:8761/eureka/apps/rest-api-test
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8761 (#0)
> POST /eureka/apps/rest-api-test HTTP/1.1
> Host: localhost:8761
> User-Agent: curl/7.57.0
> Accept: */*
> Content-type:application/xml
> Content-Length: 672
>
* upload completely sent off: 672 out of 672 bytes
< HTTP/1.1 204
< Content-Type: application/xml
< Date: Sun, 31 Dec 2017 07:44:12 GMT
<
* Connection #0 to host localhost left intact

xml文件:

<instance>
    <instanceId>stono:rest-api-test:9000</instanceId>
    <hostName>stono</hostName>
    <app>REST-API-TEST</app>
    <ipAddr>127.0.0.1</ipAddr>
    <vipAddress>rest-api-test</vipAddress>
    <secureVipAddress>rest-api-test</secureVipAddress>
    <status>UP</status>
    <port enabled="true">9000</port>
    <securePort enabled="false">433</securePort>
    <homePageUrl>http://127.0.0.1:9000</homePageUrl>
    <statusPageUrl>http://127.0.0.1:9000/info</statusPageUrl>
    <healthCheckUrl>http://27.0.0.1:9000/health</healthCheckUrl>
    <dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
        <name>MyOwn</name>
    </dataCenterInfo>
</instance>

 过一段时间后,服务会被删掉,因为就是没有这个服务;

如果使用Postman进行测试,方法选择POST,地址:http://localhost:8761/eureka/apps/rest-api-test  ,Body 选择 raw,下拉框选择 XML(application/xml); 输入框内输入XML文件;

 注销微服务:

D:\Java\IdeaProjects>curl -v -X DELETE http://localhost:8761/eureka/apps/rest-ap
i-test/stono:rest-api-test:9000
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8761 (#0)
> DELETE /eureka/apps/rest-api-test/stono:rest-api-test:9000 HTTP/1.1
> Host: localhost:8761
> User-Agent: curl/7.57.0
> Accept: */*
>
< HTTP/1.1 200
< Content-Type: application/xml
< Content-Length: 0
< Date: Sun, 31 Dec 2017 07:50:17 GMT
<
* Connection #0 to host localhost left intact

使用Postman注销微服务,方法选择DELETE,地址http://localhost:8761/eureka/apps/rest-api-test/stono:rest-api-test:9000

posted @ 2017-12-31 15:48  stono  阅读(625)  评论(1编辑  收藏  举报