Search in sources :

Example 1 with VxApiAfterHandler

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

the class VxApiApplication method initAfterHandler.

/**
 * 初始化后置路由器
 *
 * @param path
 *          路径
 * @param method
 *          类型
 * @param consumes
 *          接收类型
 * @param route
 *          路由
 * @throws Exception
 */
public void initAfterHandler(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
    VxApiAfterHandlerOptions options = api.getAfterHandlerOptions();
    VxApiAfterHandler afterHandler = VxApiAfterHandlerFactory.getAfterHandler(options.getInFactoryName(), options.getOption(), api, httpClient);
    route.handler(afterHandler);
}
Also used : VxApiAfterHandler(com.szmirren.vxApi.spi.handler.VxApiAfterHandler) VxApiAfterHandlerOptions(com.szmirren.vxApi.spi.handler.VxApiAfterHandlerOptions)

Aggregations

VxApiAfterHandler (com.szmirren.vxApi.spi.handler.VxApiAfterHandler)1 VxApiAfterHandlerOptions (com.szmirren.vxApi.spi.handler.VxApiAfterHandlerOptions)1