Search in sources :

Example 1 with VxApiAuth

use of com.szmirren.vxApi.spi.auth.VxApiAuth in project VX-API-Gateway by EliMirren.

the class VxApiApplication method initAuthHandler.

/**
 * 初始化权限认证
 *
 * @param path
 *          路径
 * @param method
 *          类型
 * @param consumes
 *          接收类型
 * @param route
 *          路由
 * @throws Exception
 */
public void initAuthHandler(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
    VxApiAuthOptions authOptions = api.getAuthOptions();
    VxApiAuth authHandler = VxApiAuthFactory.getVxApiAuth(authOptions.getInFactoryName(), authOptions.getOption(), api, httpClient);
    route.handler(authHandler);
}
Also used : VxApiAuth(com.szmirren.vxApi.spi.auth.VxApiAuth) VxApiAuthOptions(com.szmirren.vxApi.spi.auth.VxApiAuthOptions)

Aggregations

VxApiAuth (com.szmirren.vxApi.spi.auth.VxApiAuth)1 VxApiAuthOptions (com.szmirren.vxApi.spi.auth.VxApiAuthOptions)1