Commit b764713f by Nepxion

开启和关闭通过Rest方式对规则配置的控制和推送

parent 36b0e5e5
......@@ -69,6 +69,11 @@ public class ConfigEndpoint {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Discovery control is disabled");
}
Boolean isConfigRestControlEnabled = pluginContextAware.isConfigRestControlEnabled();
if (!isConfigRestControlEnabled) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Config rest control is disabled");
}
pluginEventWapper.fireRuleCleared(new RuleClearedEvent(), true);
return ResponseEntity.ok().body("OK");
......@@ -105,6 +110,11 @@ public class ConfigEndpoint {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Discovery control is disabled");
}
Boolean isConfigRestControlEnabled = pluginContextAware.isConfigRestControlEnabled();
if (!isConfigRestControlEnabled) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Config rest control is disabled");
}
try {
InputStream inputStream = IOUtils.toInputStream(config, PluginConstant.ENCODING_UTF_8);
pluginEventWapper.fireRuleUpdated(new RuleUpdatedEvent(inputStream), async);
......
......@@ -14,6 +14,7 @@ public class PluginConstant {
public static final String SPRING_APPLICATION_REGISTER_CONTROL_ENABLED = "spring.application.register.control.enabled";
public static final String SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED = "spring.application.discovery.control.enabled";
public static final String SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED = "spring.application.config.rest.control.enabled";
public static final String SPRING_APPLICATION_NAME = "spring.application.name";
public static final String SERVICE_ID = "serviceId";
......
......@@ -92,6 +92,10 @@ public class PluginContextAware implements ApplicationContextAware {
return isDiscoveryControlEnabled(environment);
}
public Boolean isConfigRestControlEnabled() {
return isConfigRestControlEnabled(environment);
}
public static Boolean isRegisterControlEnabled(Environment environment) {
return environment.getProperty(PluginConstant.SPRING_APPLICATION_REGISTER_CONTROL_ENABLED, Boolean.class, Boolean.TRUE);
}
......@@ -99,4 +103,8 @@ public class PluginContextAware implements ApplicationContextAware {
public static Boolean isDiscoveryControlEnabled(Environment environment) {
return environment.getProperty(PluginConstant.SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED, Boolean.class, Boolean.TRUE);
}
public static Boolean isConfigRestControlEnabled(Environment environment) {
return environment.getProperty(PluginConstant.SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED, Boolean.class, Boolean.TRUE);
}
}
\ No newline at end of file
......@@ -27,6 +27,8 @@ management.security.enabled=false
spring.application.register.control.enabled=true
# 开启和关闭服务发现层面的控制。一旦关闭,服务多版本调用的控制功能将失效,动态屏蔽指定IP地址的服务实例被发现的功能将失效。缺失则默认为true
spring.application.discovery.control.enabled=true
# 开启和关闭通过Rest方式对规则配置的控制和推送。一旦关闭,只能通过远程配置中心来控制和推送。缺失则默认为true
spring.application.config.rest.control.enabled=true
# Swagger config
swagger.service.base.package=com.nepxion.discovery.plugin.admincenter.endpoint
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment