Commit e38c7baf by Nepxion

优化逻辑

parent 42297028
...@@ -64,6 +64,7 @@ public class AdminEndpoint extends AbstractMvcEndpoint { ...@@ -64,6 +64,7 @@ public class AdminEndpoint extends AbstractMvcEndpoint {
this.registration = registration; this.registration = registration;
} }
// 发送规则配置信息
@RequestMapping(path = "config", method = RequestMethod.POST) @RequestMapping(path = "config", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ManagedOperation @ManagedOperation
...@@ -73,10 +74,6 @@ public class AdminEndpoint extends AbstractMvcEndpoint { ...@@ -73,10 +74,6 @@ public class AdminEndpoint extends AbstractMvcEndpoint {
return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND); return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND);
} }
if (registration == null) {
throw new PluginException("No registration found");
}
try { try {
InputStream inputStream = IOUtils.toInputStream(config, PluginConstant.ENCODING_UTF_8); InputStream inputStream = IOUtils.toInputStream(config, PluginConstant.ENCODING_UTF_8);
pluginPublisher.asyncPublish(inputStream); pluginPublisher.asyncPublish(inputStream);
...@@ -87,14 +84,11 @@ public class AdminEndpoint extends AbstractMvcEndpoint { ...@@ -87,14 +84,11 @@ public class AdminEndpoint extends AbstractMvcEndpoint {
return "success"; return "success";
} }
// 查看当前生效的规则配置信息
@RequestMapping(path = "view", method = RequestMethod.GET) @RequestMapping(path = "view", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ManagedOperation @ManagedOperation
public Object view() { public String view() {
if (registration == null) {
throw new PluginException("No registration found");
}
return ruleEntity.getContent(); return ruleEntity.getContent();
} }
...@@ -102,11 +96,6 @@ public class AdminEndpoint extends AbstractMvcEndpoint { ...@@ -102,11 +96,6 @@ public class AdminEndpoint extends AbstractMvcEndpoint {
@ResponseBody @ResponseBody
@ManagedOperation @ManagedOperation
public Object deregister() { public Object deregister() {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
if (!discoveryControlEnabled) {
return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND);
}
if (registration == null) { if (registration == null) {
throw new PluginException("No registration found"); throw new PluginException("No registration found");
} }
...@@ -122,11 +111,6 @@ public class AdminEndpoint extends AbstractMvcEndpoint { ...@@ -122,11 +111,6 @@ public class AdminEndpoint extends AbstractMvcEndpoint {
@ResponseBody @ResponseBody
@ManagedOperation @ManagedOperation
public Object status(@RequestBody String status) { public Object status(@RequestBody String status) {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
if (!discoveryControlEnabled) {
return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND);
}
if (registration == null) { if (registration == null) {
throw new PluginException("No registration found"); throw new PluginException("No registration found");
} }
......
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