1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

ans add management.endpoints.web.base-path metadata

This commit is contained in:
flystar32 2019-03-12 17:58:32 +08:00
parent 4e357de08f
commit 03788b58f9

View File

@ -37,6 +37,7 @@ public class AnsRegistration implements Registration, ServiceInstance {
static final String MANAGEMENT_PORT = "management.port";
static final String MANAGEMENT_CONTEXT_PATH = "management.context-path";
static final String MANAGEMENT_ADDRESS = "management.address";
static final String MANAGEMENT_ENDPOINT_BASE_PATH = "management.endpoints.web.base-path";
private AnsProperties ansProperties;
private ApplicationContext context;
@ -49,10 +50,16 @@ public class AnsRegistration implements Registration, ServiceInstance {
@PostConstruct
public void init() {
Map<String, String> metadata = ansProperties.getClientMetadata();
Environment env = context.getEnvironment();
String endpointBasePath = env.getProperty(MANAGEMENT_ENDPOINT_BASE_PATH);
if (!StringUtils.isEmpty(endpointBasePath)) {
metadata.put(MANAGEMENT_ENDPOINT_BASE_PATH, endpointBasePath);
}
Integer managementPort = ManagementServerPortUtils.getPort(context);
if (null != managementPort) {
Map<String, String> metadata = ansProperties.getClientMetadata();
metadata.put(MANAGEMENT_PORT, managementPort.toString());
String contextPath = env
.getProperty("management.server.servlet.context-path");