parent
0ac9a62305
commit
0fe715ca6d
@ -0,0 +1,38 @@
|
||||
package com.dsideal.Config;
|
||||
|
||||
import com.dsideal.Res.Plugin.YamlProp;
|
||||
import com.jfinal.kit.Prop;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PropKit {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PropKit.class);
|
||||
|
||||
public static String getEnvPrefix() {
|
||||
String myEnvVar = System.getenv("WORKING_ENV");
|
||||
if (myEnvVar == null) {
|
||||
myEnvVar = "dev";
|
||||
}
|
||||
return myEnvVar;
|
||||
}
|
||||
|
||||
public static Prop prop;
|
||||
public static String configFile;
|
||||
|
||||
static {
|
||||
//加载配置文件
|
||||
configFile = "application_{?}.yaml".replace("{?}", getEnvPrefix());
|
||||
prop = new YamlProp(configFile);
|
||||
}
|
||||
|
||||
public static String get(String key) {
|
||||
if (!prop.containsKey(key)) {
|
||||
throw new RuntimeException("没有找到配置文件" + configFile + "中的键值:" + key);
|
||||
}
|
||||
return prop.get(key);
|
||||
}
|
||||
|
||||
public static int getInt(String key) {
|
||||
return prop.getInt(key);
|
||||
}
|
||||
}
|
@ -1,23 +1,21 @@
|
||||
package com.dsideal.Res.Config;
|
||||
|
||||
import com.dsideal.Res.ResApplication;
|
||||
import com.jfinal.kit.Prop;
|
||||
import com.dsideal.Config.PropKit;
|
||||
|
||||
public class GatewayConfig {
|
||||
private static final Prop prop = ResApplication.PropKit;
|
||||
|
||||
// 超时配置
|
||||
public static final int CONNECT_TIMEOUT = prop.getInt("gateway.timeout.connect", 10000);
|
||||
public static final int READ_TIMEOUT = prop.getInt("gateway.timeout.read", 30000);
|
||||
public static final int WRITE_TIMEOUT = prop.getInt("gateway.timeout.write", 30000);
|
||||
public static final int CONNECT_TIMEOUT = PropKit.getInt("gateway.timeout.connect");
|
||||
public static final int READ_TIMEOUT = PropKit.getInt("gateway.timeout.read");
|
||||
public static final int WRITE_TIMEOUT = PropKit.getInt("gateway.timeout.write");
|
||||
|
||||
// 连接池配置
|
||||
public static final int MAX_CONNECTIONS = prop.getInt("gateway.connection.max", 5);
|
||||
public static final int KEEP_ALIVE_DURATION = prop.getInt("gateway.connection.keep-alive", 300);
|
||||
public static final int MAX_CONNECTIONS = PropKit.getInt("gateway.connection.max");
|
||||
public static final int KEEP_ALIVE_DURATION = PropKit.getInt("gateway.connection.keep-alive");
|
||||
|
||||
// 安全配置
|
||||
public static final String[] ALLOWED_ORIGINS = prop.get("gateway.security.cors.allowed-origins", "*").split(",");
|
||||
public static final String[] ALLOWED_METHODS = prop.get("gateway.security.cors.allowed-methods", "GET,POST,OPTIONS").split(",");
|
||||
public static final String[] ALLOWED_HEADERS = prop.get("gateway.security.cors.allowed-headers", "Content-Type,Authorization,Cookie").split(",");
|
||||
public static final boolean ALLOW_CREDENTIALS = prop.getBoolean("gateway.security.cors.allow-credentials", true);
|
||||
public static final int MAX_AGE = prop.getInt("gateway.security.cors.max-age", 3600);}
|
||||
// public static final String[] ALLOWED_ORIGINS = PropKit.get("gateway.security.cors.allowed-origins", "*").split(",");
|
||||
// public static final String[] ALLOWED_METHODS = PropKit.get("gateway.security.cors.allowed-methods", "GET,POST,OPTIONS").split(",");
|
||||
// public static final String[] ALLOWED_HEADERS = PropKit.get("gateway.security.cors.allowed-headers", "Content-Type,Authorization,Cookie").split(",");
|
||||
// public static final boolean ALLOW_CREDENTIALS = PropKit.getBoolean("gateway.security.cors.allow-credentials", true);
|
||||
// public static final int MAX_AGE = PropKit.getInt("gateway.security.cors.max-age", 3600);
|
||||
}
|
Loading…
Reference in new issue