Search in sources :

Example 1 with VxApiBeforeHandlerOptions

use of com.szmirren.vxApi.spi.handler.VxApiBeforeHandlerOptions in project VX-API-Gateway by EliMirren.

the class VxApiApplication method initBeforeHandler.

/**
 * 初始化前置路由器
 *
 * @param path
 *          路径
 * @param method
 *          类型
 * @param consumes
 *          接收类型
 * @param route
 *          路由
 * @throws Exception
 */
public void initBeforeHandler(VxApis api, Route route) throws Exception {
    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));
    }
    // 添加handler
    VxApiBeforeHandlerOptions options = api.getBeforeHandlerOptions();
    VxApiBeforeHandler beforeHandler = VxApiBeforeHandlerFactory.getBeforeHandler(options.getInFactoryName(), options.getOption(), api, httpClient);
    route.handler(beforeHandler);
}
Also used : VxApiBeforeHandlerOptions(com.szmirren.vxApi.spi.handler.VxApiBeforeHandlerOptions) VxApiBeforeHandler(com.szmirren.vxApi.spi.handler.VxApiBeforeHandler)

Aggregations

VxApiBeforeHandler (com.szmirren.vxApi.spi.handler.VxApiBeforeHandler)1 VxApiBeforeHandlerOptions (com.szmirren.vxApi.spi.handler.VxApiBeforeHandlerOptions)1