聊聊Eureka|聊聊Eureka Server的REST API
序 本文主要研究下Eureka Server的REST API
ApplicationsResource eureka-core-1.8.8-sources.jar!/com/netflix/eureka/resources/ApplicationsResource.java
@Path("/{version}/apps")
@Produces({"application/xml", "application/json"})
public class ApplicationsResource {
@Path("{appId}")
public ApplicationResource getApplicationResource(
@PathParam("version") String version,
@PathParam("appId") String appId) {
CurrentRequestVersion.set(Version.toEnum(version));
return new ApplicationResource(appId, serverConfig, registry);
}//...
@GET
public Response getContainers(@PathParam("version") String version,
@HeaderParam(HEADER_ACCEPT) String acceptHeader,
@HeaderParam(HEADER_ACCEPT_ENCODING) String acceptEncoding,
@HeaderParam(EurekaAccept.HTTP_X_EUREKA_ACCEPT) String eurekaAccept,
@Context UriInfo uriInfo,
@Nullable @QueryParam("regions") String regionsStr) {
//...
}@Path("delta")
@GET
public Response getContainerDifferential(
@PathParam("version") String version,
@HeaderParam(HEADER_ACCEPT) String acceptHeader,
@HeaderParam(HEADER_ACCEPT_ENCODING) String acceptEncoding,
@HeaderParam(EurekaAccept.HTTP_X_EUREKA_ACCEPT) String eurekaAccept,
@Context UriInfo uriInfo, @Nullable @QueryParam("regions") String regionsStr) {
//...
}}
复制代码
这里提供三个接口:
- /{version}/apps/{appId}
- /{version}/apps
- /{version}/apps/delta
对于spring cloud eureka来说,这里的version是eurekaApplicationResource eureka-core-1.8.8-sources.jar!/com/netflix/eureka/resources/ApplicationResource.java
@GET
public Response getApplication(@PathParam("version") String version,
@HeaderParam("Accept") final String acceptHeader,
@HeaderParam(EurekaAccept.HTTP_X_EUREKA_ACCEPT) String eurekaAccept) {
//...
} @Path("{id}")
public InstanceResource getInstanceInfo(@PathParam("id") String id) {
return new InstanceResource(this, id, serverConfig, registry);
}@POST
@Consumes({"application/json", "application/xml"})
public Response addInstance(InstanceInfo info,
@HeaderParam(PeerEurekaNode.HEADER_REPLICATION) String isReplication) {
//...
}
复制代码
【聊聊Eureka|聊聊Eureka Server的REST API】这里提供三个接口
- /{version}
- /{id}
- POST /
@Produces({"application/xml", "application/json"})
@Path("/{version}/instances")
public class InstancesResource {
@GET
@Path("{id}")
public Response getById(@PathParam("version") String version,
@PathParam("id") String id) {
//...
}}
复制代码
这里提供一个接口
- /{version}/instances/{id}
@Path("/{version}/status")
@Produces({"application/xml", "application/json"})
public class StatusResource {
@GET
public StatusInfo getStatusInfo() {
return statusUtil.getStatusInfo();
}
//...
}
复制代码
这里提供一个接口
- /{version}/status
@Path("/{version}/vips")
@Produces({"application/xml", "application/json"})
public class VIPResource extends AbstractVIPResource {
@GET
@Path("{vipAddress}")
public Response statusUpdate(@PathParam("version") String version,
@PathParam("vipAddress") String vipAddress,
@HeaderParam("Accept") final String acceptHeader,
@HeaderParam(EurekaAccept.HTTP_X_EUREKA_ACCEPT) String eurekaAccept) {
return getVipResponse(version, vipAddress, acceptHeader,
EurekaAccept.fromString(eurekaAccept), Key.EntityType.VIP);
}
}
复制代码
这里提供一个接口
- /{version}/vips/{vipAddress}
@Path("/{version}/svips")
@Produces({"application/xml", "application/json"})
public class SecureVIPResource extends AbstractVIPResource {
@GET
@Path("{svipAddress}")
public Response statusUpdate(@PathParam("version") String version,
@PathParam("svipAddress") String svipAddress,
@HeaderParam("Accept") final String acceptHeader,
@HeaderParam(EurekaAccept.HTTP_X_EUREKA_ACCEPT) String eurekaAccept) {
return getVipResponse(version, svipAddress, acceptHeader,
EurekaAccept.fromString(eurekaAccept), Key.EntityType.SVIP);
}
}
复制代码
这里提供一个接口
- /{version}/svips/{svipAddress}
@Path("/{version}/peerreplication")
@Produces({"application/xml", "application/json"})
public class PeerReplicationResource {
@Path("batch")
@POST
public Response batchReplication(ReplicationList replicationList) {
//....
}
}
复制代码
这里提供一个接口
- POST /{version}/peerreplication/batch
doc
- Eureka REST operations
推荐阅读
- gitlab|gitlab 通过备份还原 admin/runner 500 Internal Server Error
- 想聊聊SA,聊聊手帐,也想和你们分享自己
- SqlServer|sql server的UPDLOCK、HOLDLOCK试验
- 世外小学惨案后,和孩子聊聊世界的“复杂”
- 聊聊curator|聊聊curator recipes的LeaderLatch
- 被催稿了,所以聊聊|被催稿了,所以聊聊 长链接在移动端开发中如何做到和短链接一样高效
- python之SimpleHTTPServer用法
- 2019-07-08|2019-07-08 windows server
- 网络|简单聊聊压缩网络
- 如何用Serverless云函数做免费私域运营机器人