zoukankan      html  css  js  c++  java
  • Eureka Server的REST端点

    Eureka Server的REST端点

    Windows下面可以安装Curl;

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

    D:JavaIdeaProjects>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:JavaIdeaProjects>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

  • 相关阅读:
    流水线电子看板的设计与实现
    ASP.NET MVC 5 Web编程4 -- Razor视图引擎
    实战:上亿数据如何秒查
    ASP.NET MVC 5 Web编程3 -- Controller的应用及扩展
    ASP.NET MVC 5 Web编程2 -- URL映射(路由原理)
    ASP.NET MVC 5 Web编程1 -- 入门
    IIS发布站点错误收集(持续更新)
    .NET垃圾回收(GC)原理
    SSRS(rdl报表)分页显示表头和对表头的冻结处理
    《CLR.via.C#第三版》第二部分第13章节 接口 读书笔记(七)
  • 原文地址:https://www.cnblogs.com/stono/p/8157853.html
Copyright © 2011-2022 走看看