This commit is contained in:
tanghc
2019-05-06 15:10:37 +08:00
parent 0db229053f
commit 2953f7dc77
26 changed files with 201 additions and 122 deletions

View File

@@ -23,7 +23,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.1-SNAPSHOT</version>
</dependency>
<!-- ↓↓↓ 使用spring cloud zuul ↓↓↓ -->

View File

@@ -0,0 +1,31 @@
package com.gitee.sop.gateway;
import com.gitee.sop.gatewaycommon.bean.SopConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
/**
* @author tanghc
*/
@Controller
public class RedirectController {
@Value("${zuul.servlet-path}")
private String path;
@RequestMapping("/{method}/{version}/")
public String redirect(
@PathVariable("method") String method
, @PathVariable("version") String version
, HttpServletRequest request
) {
request.setAttribute(SopConstants.REDIRECT_METHOD_KEY, method);
request.setAttribute(SopConstants.REDIRECT_VERSION_KEY, version);
return "forward:" + path;
}
}