Newer
Older
newfiber-termite / newfiber-gateway / src / main / java / com / newfiber / gateway / config / RouterFunctionConfiguration.java
@yanghui yanghui on 11 May 987 bytes 白蚁项目初版代码提交
package com.newfiber.gateway.config;

import com.newfiber.gateway.handler.ValidateCodeHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;

/**
 * 路由配置信息
 * 
 * @author newfiber
 */
@Configuration
public class RouterFunctionConfiguration{
    @Autowired
    private ValidateCodeHandler validateCodeHandler;

    @SuppressWarnings("rawtypes")
    @Bean
    public RouterFunction routerFunction(){
        return RouterFunctions.route(
                RequestPredicates.GET("/code").and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
                validateCodeHandler);
    }
}