Skip to content

Commit

Permalink
添加应用黑名单返回,添加处理业务逻辑的HttpClient拓展配置,API添加body透传,优化HTTP/HTTPS类型的服务处理器(尚未完成)
Browse files Browse the repository at this point in the history
  • Loading branch information
shenzhenMirren committed May 4, 2018
1 parent 4c6fe8e commit f713d20
Show file tree
Hide file tree
Showing 19 changed files with 569 additions and 137 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/szmirren/vxApi/core/VxApiLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static void main(String[] args) {
System.setProperty("thisVertxName", thisVertxName);
InternalLoggerFactory.setDefaultFactory(Log4J2LoggerFactory.INSTANCE);
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.Log4j2LogDelegateFactory");
System.setProperty("vertx.disableDnsResolver", "true");
new VxApiLauncher().dispatch(args);
}

Expand Down
83 changes: 60 additions & 23 deletions src/main/java/com/szmirren/vxApi/core/entity/VxApis.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,44 @@
*
*/
public class VxApis {
private String appName;// 应用网关的名字
private String apiName;// API的名字
private String apiDescribe;// API的描述
private Instant apiCreateTime;// API的创建时间
private TimeUnitEnum limitUnit;// 访问限制单位
private long apiLimit;// API访问限制次数
private long ipLimit;// IP访问限制次数
private String path;// 接口路径
private VxApiAuthOptions authOptions;// 权限配置信息
private VxApiBeforeHandlerOptions beforeHandlerOptions;// 前置处理器配置信息
private VxApiAfterHandlerOptions afterHandlerOptions;// 后置处理器配置信息
private String contentType;// 返回的Content-Type类型
private Set<String> consumes;// 接口consumes
private HttpMethodEnum method;// 请求方法类型
private List<VxApiEntranceParam> enterParam;// 参数的配置
private VxApiServerEntrance serverEntrance;// API 服务端入口
private VxApiResult result;// API返回结果
/** 应用网关的名字 */
private String appName;
/** API的名字 */
private String apiName;
/** API的描述 */
private String apiDescribe;
/** API的创建时间 */
private Instant apiCreateTime;
/** 访问限制单位 */
private TimeUnitEnum limitUnit;
/** API访问限制次数 */
private long apiLimit;
/** IP访问限制次数 */
private long ipLimit;
/** 是否透传body */
private boolean passBody;
/** 是否将body的参数映射到query允许被query访问 */
private boolean bodyAsQuery = true;
/** 接口路径 */
private String path;
/** 权限配置信息 */
private VxApiAuthOptions authOptions;
/** 前置处理器配置信息 */
private VxApiBeforeHandlerOptions beforeHandlerOptions;
/** 后置处理器配置信息 */
private VxApiAfterHandlerOptions afterHandlerOptions;
/** 返回的Content-Type类型 */
private String contentType;
/** 接口consumes */
private Set<String> consumes;
/** 请求方法类型 */
private HttpMethodEnum method;
/** 参数的配置 */
private List<VxApiEntranceParam> enterParam;
/** API 服务端入口 */
private VxApiServerEntrance serverEntrance;
/** API返回结果 */
private VxApiResult result;

public VxApis(VxApisDTO option) {
super();
Expand All @@ -48,6 +69,8 @@ public VxApis(VxApisDTO option) {
this.limitUnit = option.getLimitUnit();
this.apiLimit = option.getApiLimit();
this.ipLimit = option.getIpLimit();
this.passBody = option.isPassBody();
this.bodyAsQuery = option.isBodyAsQuery();
this.authOptions = option.getAuthOptions();
this.beforeHandlerOptions = option.getBeforeHandlerOptions();
this.afterHandlerOptions = option.getAfterHandlerOptions();
Expand Down Expand Up @@ -112,6 +135,22 @@ public long getIpLimit() {
return ipLimit;
}

public boolean isPassBody() {
return passBody;
}

public void setPassBody(boolean passBody) {
this.passBody = passBody;
}

public boolean isBodyAsQuery() {
return bodyAsQuery;
}

public void setBodyAsQuery(boolean bodyAsQuery) {
this.bodyAsQuery = bodyAsQuery;
}

public VxApiAuthOptions getAuthOptions() {
return authOptions;
}
Expand Down Expand Up @@ -202,12 +241,10 @@ public void setResult(VxApiResult result) {

@Override
public String toString() {
return "VxApis [apiName=" + apiName + ", apiDescribe=" + apiDescribe + ", apiCreateTime=" + apiCreateTime
+ ", limitUnit=" + limitUnit + ", apiLimit=" + apiLimit + ", ipLimit=" + ipLimit + ", path=" + path
+ ", authOptions=" + authOptions + ", beforeHandlerOptions=" + beforeHandlerOptions
+ ", afterHandlerOptions=" + afterHandlerOptions + ", contentType=" + contentType + ", consumes="
+ consumes + ", method=" + method + ", enterParam=" + enterParam + ", serverEntrance=" + serverEntrance
+ ", result=" + result + "]";
return "VxApis [apiName=" + apiName + ", apiDescribe=" + apiDescribe + ", apiCreateTime=" + apiCreateTime + ", limitUnit=" + limitUnit
+ ", apiLimit=" + apiLimit + ", ipLimit=" + ipLimit + ", path=" + path + ", authOptions=" + authOptions + ", beforeHandlerOptions="
+ beforeHandlerOptions + ", afterHandlerOptions=" + afterHandlerOptions + ", contentType=" + contentType + ", consumes=" + consumes
+ ", method=" + method + ", enterParam=" + enterParam + ", serverEntrance=" + serverEntrance + ", result=" + result + "]";
}

}
29 changes: 23 additions & 6 deletions src/main/java/com/szmirren/vxApi/core/enums/ContentTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,36 @@
* @author <a href="http://szmirren.com">Mirren</a>
*/
public enum ContentTypeEnum {

JSON("application/json"),
/** 内容: application/json */
JSON("application/json"),
/** 内容: application/xml */
XML("application/xml"),
HTML("text/html"),
/** 内容: text/html */
HTML("text/html"),
/** 内容: text/plain */
TEXT("text/plain"),
/** 内容: application/x-www-form-urlencoded */
FORM("application/x-www-form-urlencoded"),
/** 内容: application/x-www-form-urlencoded */
APPLICATION_X_WWW_FORM_URLENCODED("application/x-www-form-urlencoded"),
/** 内容: multipart/form-data */
MULTIPART_FORM_DATA("multipart/form-data"),
/** 内容: application/octet-stream */
BINARY("application/octet-stream"),
JSON_UTF8("application/json;charset=UTF-8"),
/** 内容: application/json;charset=UTF-8 */
JSON_UTF8("application/json;charset=UTF-8"),
/** 内容: application/xml;charset=UTF-8 */
XML_UTF8("application/xml;charset=UTF-8"),
HTML_UTF8("text/html;charset=UTF-8"),
/** 内容: text/html;charset=UTF-8 */
HTML_UTF8("text/html;charset=UTF-8"),
/** 内容: text/plain;charset=UTF-8 */
TEXT_UTF8("text/plain;charset=UTF-8"),
/** 内容: application/x-www-form-urlencoded;charset=UTF-8 */
FORM_UTF8("application/x-www-form-urlencoded;charset=UTF-8"),
BINARY_UTF8("application/octet-stream;charset=UTF-8");
/** 内容: application/octet-stream;charset=UTF-8 */
BINARY_UTF8("application/octet-stream;charset=UTF-8"),
/** 内容: Content-Type */
CONTENT_TYPE("Content-Type");

private String type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
*
*/
public enum ParamPositionEnum {
PATH, QUERY, FROM, HEADER;
PATH, QUERY, BODY, HEADER;
}
Loading

0 comments on commit f713d20

Please sign in to comment.