|
@@ -0,0 +1,39 @@
|
|
|
|
|
+package com.leanwo.gateway.rest;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
|
+import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
|
|
|
+import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 上海工具厂的项目添加路由跳转
|
|
|
|
|
+ * 举例:
|
|
|
|
|
+ * https://prodog.leanwo.com/StwcApp/stwc.html?barCode=N100495
|
|
|
|
|
+ * 跳转到
|
|
|
|
|
+ * http://stwc.leanwo.com/StwcApp/stwc.html?barCode=N100495
|
|
|
|
|
+ * @author YangZhiJie
|
|
|
|
|
+ * @date 2022/06/29
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+public class RedirectController {
|
|
|
|
|
+
|
|
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(RedirectController.class);
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping(value = "/StwcApp/**")
|
|
|
|
|
+ public void redirect(ServerHttpRequest request, ServerHttpResponse response) {
|
|
|
|
|
+ String url = request.getURI().toString();
|
|
|
|
|
+ if(url.contains("prodog.leanwo.com")) {
|
|
|
|
|
+ url = url.replace("prodog.leanwo.com", "stwc.leanwo.com");
|
|
|
|
|
+ url = url.replace("https:", "http:");
|
|
|
|
|
+ logger.debug("跳转路由:" + url);
|
|
|
|
|
+ //1. 设置状态码为302
|
|
|
|
|
+ response.setStatusCode(HttpStatus.valueOf(302));
|
|
|
|
|
+ response.getHeaders().set(HttpHeaders.LOCATION, url);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|