parent
0db229053f
commit
2953f7dc77
@ -1,25 +1,25 @@ |
||||
* [首页](/?t=1557111672942) |
||||
* [首页](/?t=1557125401034) |
||||
* 开发文档 |
||||
* [快速体验](files/10010_快速体验.md?t=1557111672945) |
||||
* [项目接入到SOP](files/10011_项目接入到SOP.md?t=1557111672960) |
||||
* [新增接口](files/10020_新增接口.md?t=1557111672961) |
||||
* [业务参数校验](files/10030_业务参数校验.md?t=1557111672961) |
||||
* [错误处理](files/10040_错误处理.md?t=1557111672961) |
||||
* [编写文档](files/10041_编写文档.md?t=1557111672961) |
||||
* [接口交互详解](files/10050_接口交互详解.md?t=1557111672961) |
||||
* [easyopen支持](files/10070_easyopen支持.md?t=1557111672961) |
||||
* [使用签名校验工具](files/10080_使用签名校验工具.md?t=1557111672961) |
||||
* [ISV管理](files/10085_ISV管理.md?t=1557111672961) |
||||
* [路由授权](files/10090_路由授权.md?t=1557111672961) |
||||
* [接口限流](files/10092_接口限流.md?t=1557111672961) |
||||
* [SDK开发](files/10095_SDK开发.md?t=1557111672962) |
||||
* [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1557111672962) |
||||
* [应用授权](files/10097_应用授权.md?t=1557111672962) |
||||
* [更改数据节点名称](files/10099_更改数据节点名称.md?t=1557111672962) |
||||
* [对接前端](files/10100_对接前端.md?t=1557111672962) |
||||
* [快速体验](files/10010_快速体验.md?t=1557125401037) |
||||
* [项目接入到SOP](files/10011_项目接入到SOP.md?t=1557125401053) |
||||
* [新增接口](files/10020_新增接口.md?t=1557125401053) |
||||
* [业务参数校验](files/10030_业务参数校验.md?t=1557125401053) |
||||
* [错误处理](files/10040_错误处理.md?t=1557125401053) |
||||
* [编写文档](files/10041_编写文档.md?t=1557125401053) |
||||
* [接口交互详解](files/10050_接口交互详解.md?t=1557125401053) |
||||
* [easyopen支持](files/10070_easyopen支持.md?t=1557125401053) |
||||
* [使用签名校验工具](files/10080_使用签名校验工具.md?t=1557125401053) |
||||
* [ISV管理](files/10085_ISV管理.md?t=1557125401053) |
||||
* [路由授权](files/10090_路由授权.md?t=1557125401054) |
||||
* [接口限流](files/10092_接口限流.md?t=1557125401054) |
||||
* [SDK开发](files/10095_SDK开发.md?t=1557125401054) |
||||
* [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1557125401054) |
||||
* [应用授权](files/10097_应用授权.md?t=1557125401054) |
||||
* [更改数据节点名称](files/10099_更改数据节点名称.md?t=1557125401054) |
||||
* [对接前端](files/10100_对接前端.md?t=1557125401054) |
||||
* 原理分析 |
||||
* [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1557111672962) |
||||
* [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1557111672962) |
||||
* [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1557111672962) |
||||
* [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1557111672963) |
||||
* [常见问题](files/90100_常见问题.md?t=1557111672963) |
||||
* [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1557125401054) |
||||
* [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1557125401054) |
||||
* [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1557125401054) |
||||
* [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1557125401055) |
||||
* [常见问题](files/90100_常见问题.md?t=1557125401055) |
||||
|
@ -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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,61 @@ |
||||
package com.gitee.sop; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.gitee.sop.alipay.AlipaySignature; |
||||
import org.junit.Test; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author tanghc |
||||
*/ |
||||
public class RestUrlTest extends TestBase { |
||||
|
||||
String appId = "2019032617262200001"; |
||||
// 支付宝私钥
|
||||
String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCXJv1pQFqWNA/++OYEV7WYXwexZK/J8LY1OWlP9X0T6wHFOvxNKRvMkJ5544SbgsJpVcvRDPrcxmhPbi/sAhdO4x2PiPKIz9Yni2OtYCCeaiE056B+e1O2jXoLeXbfi9fPivJZkxH/tb4xfLkH3bA8ZAQnQsoXA0SguykMRZntF0TndUfvDrLqwhlR8r5iRdZLB6F8o8qXH6UPDfNEnf/K8wX5T4EB1b8x8QJ7Ua4GcIUqeUxGHdQpzNbJdaQvoi06lgccmL+PHzminkFYON7alj1CjDN833j7QMHdPtS9l7B67fOU/p2LAAkPMtoVBfxQt9aFj7B8rEhGCz02iJIBAgMBAAECggEARqOuIpY0v6WtJBfmR3lGIOOokLrhfJrGTLF8CiZMQha+SRJ7/wOLPlsH9SbjPlopyViTXCuYwbzn2tdABigkBHYXxpDV6CJZjzmRZ+FY3S/0POlTFElGojYUJ3CooWiVfyUMhdg5vSuOq0oCny53woFrf32zPHYGiKdvU5Djku1onbDU0Lw8w+5tguuEZ76kZ/lUcccGy5978FFmYpzY/65RHCpvLiLqYyWTtaNT1aQ/9pw4jX9HO9NfdJ9gYFK8r/2f36ZE4hxluAfeOXQfRC/WhPmiw/ReUhxPznG/WgKaa/OaRtAx3inbQ+JuCND7uuKeRe4osP2jLPHPP6AUwQKBgQDUNu3BkLoKaimjGOjCTAwtp71g1oo+k5/uEInAo7lyEwpV0EuUMwLA/HCqUgR4K9pyYV+Oyb8d6f0+Hz0BMD92I2pqlXrD7xV2WzDvyXM3s63NvorRooKcyfd9i6ccMjAyTR2qfLkxv0hlbBbsPHz4BbU63xhTJp3Ghi0/ey/1HQKBgQC2VsgqC6ykfSidZUNLmQZe3J0p/Qf9VLkfrQ+xaHapOs6AzDU2H2osuysqXTLJHsGfrwVaTs00ER2z8ljTJPBUtNtOLrwNRlvgdnzyVAKHfOgDBGwJgiwpeE9voB1oAV/mXqSaUWNnuwlOIhvQEBwekqNyWvhLqC7nCAIhj3yvNQKBgQCqYbeec56LAhWP903Zwcj9VvG7sESqXUhIkUqoOkuIBTWFFIm54QLTA1tJxDQGb98heoCIWf5x/A3xNI98RsqNBX5JON6qNWjb7/dobitti3t99v/ptDp9u8JTMC7penoryLKK0Ty3bkan95Kn9SC42YxaSghzqkt+uvfVQgiNGQKBgGxU6P2aDAt6VNwWosHSe+d2WWXt8IZBhO9d6dn0f7ORvcjmCqNKTNGgrkewMZEuVcliueJquR47IROdY8qmwqcBAN7Vg2K7r7CPlTKAWTRYMJxCT1Hi5gwJb+CZF3+IeYqsJk2NF2s0w5WJTE70k1BSvQsfIzAIDz2yE1oPHvwVAoGAA6e+xQkVH4fMEph55RJIZ5goI4Y76BSvt2N5OKZKd4HtaV+eIhM3SDsVYRLIm9ZquJHMiZQGyUGnsvrKL6AAVNK7eQZCRDk9KQz+0GKOGqku0nOZjUbAu6A2/vtXAaAuFSFx1rUQVVjFulLexkXR3KcztL1Qu2k5pB6Si0K/uwQ="; |
||||
|
||||
/** |
||||
* 演示将接口名版本号跟在url后面,规则:http://host:port/{method}/{version}/
|
||||
* @throws Exception |
||||
*/ |
||||
@Test |
||||
public void testDemo() throws Exception { |
||||
// 公共请求参数
|
||||
Map<String, String> params = new HashMap<String, String>(); |
||||
params.put("app_id", appId); |
||||
// 参数中的接口名和版本转移到了url中
|
||||
// params.put("method", "story.demo.get");
|
||||
// params.put("version", "1.0");
|
||||
// 注意这里的url
|
||||
String url = "http://localhost:8081/story.demo.get/1.0/"; |
||||
params.put("format", "json"); |
||||
params.put("charset", "utf-8"); |
||||
params.put("sign_type", "RSA2"); |
||||
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
||||
|
||||
// 业务参数
|
||||
Map<String, String> bizContent = new HashMap<>(); |
||||
|
||||
params.put("biz_content", JSON.toJSONString(bizContent)); |
||||
|
||||
System.out.println("----------- 请求信息 -----------"); |
||||
System.out.println("请求参数:" + buildParamQuery(params)); |
||||
System.out.println("商户秘钥:" + privateKey); |
||||
String content = AlipaySignature.getSignContent(params); |
||||
System.out.println("待签名内容:" + content); |
||||
String sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8"); |
||||
System.out.println("签名(sign):" + sign); |
||||
|
||||
params.put("sign", sign); |
||||
|
||||
System.out.println("----------- 返回结果 -----------"); |
||||
String responseData = post(url, params);// 发送请求
|
||||
System.out.println(responseData); |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue