Skip to content

Commit 5f351c1

Browse files
committed
Rename pkg
1 parent 8d8f598 commit 5f351c1

3 files changed

Lines changed: 898 additions & 900 deletions

File tree

src/main/java/we/plugin/pathcache/PathCacheConfig.java renamed to src/main/java/com/fizzgate/plugin/pathcache/PathCacheConfig.java

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,55 @@
1-
package we.plugin.pathcache;
2-
3-
import java.util.ArrayList;
4-
import java.util.Collections;
5-
import java.util.List;
6-
7-
import org.springframework.context.annotation.Configuration;
8-
9-
import com.fizzgate.config.ManualApiConfig;
10-
import com.fizzgate.plugin.PluginConfig;
11-
import com.fizzgate.plugin.auth.ApiConfig;
12-
import com.fizzgate.plugin.requestbody.RequestBodyPlugin;
13-
14-
/**
15-
* 定义 DemoApiConfig 继承 ManualApiConfig,并注解为 Configuration,然后实现 setApiConfigs
16-
* 方法,在方法中添加路由配置; 本类仅为方便开发和测试,正式环境应该通过管理后台配置路由
17-
*/
18-
// @Configuration
19-
public class PathCacheConfig extends ManualApiConfig {
20-
21-
@Override
22-
public List<ApiConfig> setApiConfigs() {
23-
24-
List<ApiConfig> apiConfigs = new ArrayList<>();
25-
26-
// 一个路由配置
27-
ApiConfig ac = new ApiConfig();
28-
// 路由 id,建议从 1000 开始
29-
ac.id = 1000;
30-
// 前端服务名
31-
ac.service = "cache";
32-
// 前端路径
33-
ac.path = "/test";
34-
// 路由类型,此处为反向代理
35-
ac.type = ApiConfig.Type.REVERSE_PROXY;
36-
// 被代理接口的地址
37-
ac.httpHostPorts = Collections.singletonList("http://10.100.113.28:9090");
38-
// 被代理接口的路径
39-
ac.backendPath = "/web/check";
40-
ac.pluginConfigs = new ArrayList<>();
41-
42-
// 如果你的插件需要访问请求体,则首先要把 RequestBodyPlugin.REQUEST_BODY_PLUGIN 加到 ac.pluginConfigs
43-
// 中,就像下面这样
44-
PluginConfig pc1 = new PluginConfig();
45-
pc1.plugin = RequestBodyPlugin.REQUEST_BODY_PLUGIN;
46-
ac.pluginConfigs.add(pc1);
47-
48-
PluginConfig pc2 = new PluginConfig();
49-
pc2.plugin = PathCacheFilter.PATH_CACHE_ID; // 应用 id 为 demoPlugin 的插件
50-
ac.pluginConfigs.add(pc2);
51-
52-
apiConfigs.add(ac);
53-
54-
log.info("set api configs end");
55-
return apiConfigs; // 返回路由配置
56-
}
57-
}
1+
package com.fizzgate.plugin.pathcache;
2+
3+
import java.util.ArrayList;
4+
import java.util.Collections;
5+
import java.util.List;
6+
7+
import com.fizzgate.config.ManualApiConfig;
8+
import com.fizzgate.plugin.PluginConfig;
9+
import com.fizzgate.plugin.auth.ApiConfig;
10+
import com.fizzgate.plugin.requestbody.RequestBodyPlugin;
11+
12+
/**
13+
* 定义 DemoApiConfig 继承 ManualApiConfig,并注解为 Configuration,然后实现 setApiConfigs
14+
* 方法,在方法中添加路由配置; 本类仅为方便开发和测试,正式环境应该通过管理后台配置路由
15+
*/
16+
// @Configuration
17+
public class PathCacheConfig extends ManualApiConfig {
18+
19+
@Override
20+
public List<ApiConfig> setApiConfigs() {
21+
22+
List<ApiConfig> apiConfigs = new ArrayList<>();
23+
24+
// 一个路由配置
25+
ApiConfig ac = new ApiConfig();
26+
// 路由 id,建议从 1000 开始
27+
ac.id = 1000;
28+
// 前端服务名
29+
ac.service = "cache";
30+
// 前端路径
31+
ac.path = "/test";
32+
// 路由类型,此处为反向代理
33+
ac.type = ApiConfig.Type.REVERSE_PROXY;
34+
// 被代理接口的地址
35+
ac.httpHostPorts = Collections.singletonList("http://10.100.113.28:9090");
36+
// 被代理接口的路径
37+
ac.backendPath = "/web/check";
38+
ac.pluginConfigs = new ArrayList<>();
39+
40+
// 如果你的插件需要访问请求体,则首先要把 RequestBodyPlugin.REQUEST_BODY_PLUGIN 加到 ac.pluginConfigs
41+
// 中,就像下面这样
42+
PluginConfig pc1 = new PluginConfig();
43+
pc1.plugin = RequestBodyPlugin.REQUEST_BODY_PLUGIN;
44+
ac.pluginConfigs.add(pc1);
45+
46+
PluginConfig pc2 = new PluginConfig();
47+
pc2.plugin = PathCacheFilter.PATH_CACHE_ID; // 应用 id 为 demoPlugin 的插件
48+
ac.pluginConfigs.add(pc2);
49+
50+
apiConfigs.add(ac);
51+
52+
log.info("set api configs end");
53+
return apiConfigs; // 返回路由配置
54+
}
55+
}

0 commit comments

Comments
 (0)