package ink.wgink.gateway.router.sign;

import ink.wgink.gateway.consts.ISystemConst;
import ink.wgink.gateway.handler.BaseHandler;
import ink.wgink.gateway.handler.route.RouteHandler;
import ink.wgink.gateway.handler.sign.SignHandler;
import ink.wgink.gateway.router.BaseRouter;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: SignRouter
 * @Description: 登录登出
 * @Author: wanggeng
 * @Date: 2021/4/23 4:02 下午
 * @Version: 1.0
 */
@Component
public class SignRouter extends BaseRouter {

    @Bean
    public RouterFunction<ServerResponse> signRouterFunction(SignHandler signHandler) {
        return RouterFunctions.nest(RequestPredicates.path(ISystemConst.ADMIN_ROUTER_PREFIX + "/api/sign"),
                RouterFunctions
                        .route(RequestPredicates.POST("/in"), signHandler::in)
                        .andRoute(RequestPredicates.GET("/out"), signHandler::out));
    }

}
