Search in sources :

Example 1 with VxApiRouteHandlerApiLimit

use of com.szmirren.vxApi.core.handler.route.VxApiRouteHandlerApiLimit in project VX-API-Gateway by EliMirren.

the class VxApiApplication method initApiLimit.

/**
 * 初始化流量限制
 *
 * @param api
 * @param route
 */
public void initApiLimit(VxApis api, Route route) {
    route.path(api.getPath());
    if (api.getMethod() != HttpMethodEnum.ALL) {
        route.method(HttpMethod.valueOf(api.getMethod().getVal()));
    }
    // 添加consumes
    if (api.getConsumes() != null) {
        api.getConsumes().forEach(va -> route.consumes(va));
    }
    if (api.getLimitUnit() != null) {
        if (api.getApiLimit() <= -1 && api.getIpLimit() <= -1) {
            api.setLimitUnit(null);
        }
    }
    // 流量限制处理处理器
    VxApiRouteHandlerApiLimit apiLimitHandler = VxApiRouteHandlerApiLimit.create(api);
    route.handler(apiLimitHandler);
}
Also used : VxApiRouteHandlerApiLimit(com.szmirren.vxApi.core.handler.route.VxApiRouteHandlerApiLimit)

Aggregations

VxApiRouteHandlerApiLimit (com.szmirren.vxApi.core.handler.route.VxApiRouteHandlerApiLimit)1