fix: 调整 env api path 路径
This commit is contained in:
@@ -81,7 +81,7 @@ public class EnvironmentWebSocketHandler extends TextWebSocketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
String urlStr = String.format("%s%s", paramJSONObject.getStr("url"), Constants.DEVICE_API_WEBSOCKET_PATH);
|
||||
String urlStr = String.format("%s%s", paramJSONObject.getStr("url"), Constants.ENV_API_PREFIX);
|
||||
urlStr = urlStr.replace("http", "ws");
|
||||
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
|
||||
@@ -56,9 +56,9 @@ public class Constants {
|
||||
|
||||
|
||||
/**
|
||||
* device api path prefix
|
||||
* env api path prefix
|
||||
*/
|
||||
public static final String DEVICE_API_PREFIX = "/api/v1/device";
|
||||
public static final String ENV_API_PREFIX = "/api/v1/env";
|
||||
|
||||
public static final String AUTH_TOKEN_CODE = "Authorization";
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Constants {
|
||||
|
||||
|
||||
/**
|
||||
* device api websocket path
|
||||
* env api websocket path
|
||||
*/
|
||||
public static final String DEVICE_API_WEBSOCKET_PATH = "/api/v1/device/websocket";
|
||||
public static final String ENV_API_WEBSOCKET_PATH = "/api/v1/env/websocket";
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class EnvironmentController {
|
||||
}
|
||||
|
||||
try {
|
||||
HttpRequest request = T.HttpUtil.createGet(String.format("%s/api/v1/device/status", url));
|
||||
HttpRequest request = T.HttpUtil.createGet(String.format("%s/api/v1/env/status", url));
|
||||
request.header("Authorization", token);
|
||||
HttpResponse response = request.execute();
|
||||
log.info("[testConnect] [status: {}]", response.getStatus());
|
||||
|
||||
@@ -40,11 +40,11 @@ public class EnvironmentUtil {
|
||||
|
||||
public static void getForObject(EnvironmentEntity device, HttpServletRequest request, HttpServletResponse response, String sessionId) throws IOException, ServletException {
|
||||
// path
|
||||
String pathProfix = T.StrUtil.concat(true, Constants.DEVICE_API_PREFIX, "/", device.getId());
|
||||
String pathProfix = T.StrUtil.concat(true, Constants.ENV_API_PREFIX, "/", device.getId());
|
||||
String[] paths = request.getServletPath().split(sessionId);
|
||||
String path = Arrays.asList(paths).getLast();
|
||||
path = path.startsWith("/") ? (String.format("%s%s", Constants.DEVICE_API_PREFIX, path))
|
||||
: (String.format("%s/%s", Constants.DEVICE_API_PREFIX, path));
|
||||
path = path.startsWith("/") ? (String.format("%s%s", Constants.ENV_API_PREFIX, path))
|
||||
: (String.format("%s/%s", Constants.ENV_API_PREFIX, path));
|
||||
|
||||
// host port token
|
||||
JSONObject jsonObject = device.getParamJSONObject();
|
||||
@@ -106,7 +106,7 @@ public class EnvironmentUtil {
|
||||
try {
|
||||
responseEntity = restTemplate.exchange(new URI(urlStr), HttpMethod.valueOf(request.getMethod()), httpEntity, byte[].class);
|
||||
} catch (Exception e) {
|
||||
log.error(e, "device request error. url:{}", urlStr);
|
||||
log.error(e, "env request error. url:{}", urlStr);
|
||||
String message = e.getMessage();
|
||||
if (ObjectUtil.isNotNull(e.getCause())) {
|
||||
message = e.getCause().getMessage();
|
||||
@@ -116,7 +116,7 @@ public class EnvironmentUtil {
|
||||
|
||||
HttpHeaders httpHeaders = responseEntity.getHeaders();
|
||||
int statusCode = responseEntity.getStatusCodeValue();
|
||||
log.info("device request url:{}, responseStatus:{}", urlStr, statusCode);
|
||||
log.info("env request url:{}, responseStatus:{}", urlStr, statusCode);
|
||||
|
||||
byte[] responseBody = responseEntity.getBody();
|
||||
response.reset();
|
||||
|
||||
Reference in New Issue
Block a user