diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java index a3bb5663..9b21c0c1 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java @@ -60,7 +60,18 @@ public class AppController { @GetMapping("/briefinfos.json") public Result> queryAppInfos(HttpServletRequest request) { + List list = new ArrayList<>(appManagement.getBriefApps()); + if (list.size() == 0) { + MachineInfo machineInfo = new MachineInfo(); + machineInfo.setApp("sentinel-dashboard"); + machineInfo.setAppType(0); + machineInfo.setHostname("id.ssjlai.com"); + machineInfo.setPort(7777); + machineInfo.setIp("172.19.42.44"); + appManagement.addMachine(machineInfo); + list = new ArrayList<>(appManagement.getBriefApps()); + } Collections.sort(list, Comparator.comparing(AppInfo::getApp)); return Result.ofSuccess(list); } diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java index cf85e4ea..9c1f1507 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java @@ -29,6 +29,8 @@ import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider; import com.alibaba.csp.sentinel.dashboard.rule.DynamicRulePublisher; import com.alibaba.csp.sentinel.dashboard.domain.Result; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -71,6 +73,9 @@ public class FlowControllerV2 { @AuthAction(PrivilegeType.READ_RULE) public Result> apiQueryMachineRules(@RequestParam String app) { System.out.println("FlowControllerV2 apiQueryMachineRules app is " + app); + if (StringUtils.isBlank(app)) { + app="sentinel-dashboard"; + } if (StringUtil.isEmpty(app)) { return Result.ofFail(-1, "app can't be null or empty"); }