com.nepxion.discovery.plugin.admincenter.endpoint.InspectorEndpoint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-plugin-admin-center-starter Show documentation
Show all versions of discovery-plugin-admin-center-starter Show documentation
Nepxion Discovery is a solution for Spring Cloud with blue green, gray, weight, limitation, circuit breaker, degrade, isolation, monitor, tracing, dye, failover, async agent
The newest version!
package com.nepxion.discovery.plugin.admincenter.endpoint;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.nepxion.discovery.common.entity.InspectorEntity;
import com.nepxion.discovery.common.util.ResponseUtil;
import com.nepxion.discovery.plugin.admincenter.resource.InspectorResource;
@RestController
@RequestMapping(path = "/inspector")
public class InspectorEndpoint {
@Autowired
private InspectorResource inspectorResource;
@RequestMapping(path = "/inspect", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity> inspect(@RequestBody InspectorEntity inspectorEntity) {
return doInspect(inspectorEntity);
}
@RequestMapping(path = "/inspect-service", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity> inspect(@RequestBody List service) {
return doInspect(service);
}
private ResponseEntity> doInspect(InspectorEntity inspectorEntity) {
try {
InspectorEntity result = inspectorResource.inspect(inspectorEntity);
return ResponseUtil.getSuccessResponse(result);
} catch (Exception e) {
return ResponseUtil.getFailureResponse(e);
}
}
private ResponseEntity> doInspect(List service) {
try {
String result = inspectorResource.inspect(service);
return ResponseUtil.getSuccessResponse(result);
} catch (Exception e) {
return ResponseUtil.getFailureResponse(e);
}
}
}