Created
September 9, 2019 07:07
-
-
Save warpgate3/d1d350d0f51a043ebca7da943d72703d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.m2sj.springfluxandredis; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.http.MediaType; | |
import org.springframework.web.reactive.function.BodyInserters; | |
import org.springframework.web.reactive.function.server.RouterFunction; | |
import org.springframework.web.reactive.function.server.ServerResponse; | |
import static org.springframework.web.reactive.function.server.RouterFunctions.route; | |
@Configuration | |
public class BasicRouter { | |
private final BasicService basicService; | |
public BasicRouter(BasicService basicService) { | |
this.basicService = basicService; | |
} | |
@Bean | |
RouterFunction<ServerResponse> empRouterList() { | |
return route() | |
.GET("/reactive-list", serverRequest -> ServerResponse.ok().contentType(MediaType.TEXT_HTML).body(basicService.findReactorList(), String.class)) | |
.GET("/normal-list", serverRequest -> ServerResponse.ok().contentType(MediaType.TEXT_HTML).body(basicService.findNormalList(), String.class)) | |
.GET("/load", serverRequest -> { | |
basicService.loadData(); | |
return ServerResponse.ok().body(BodyInserters.fromObject("Load Data Completed")); | |
}) | |
.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment