Skip to content

Instantly share code, notes, and snippets.

@warpgate3
Created September 9, 2019 07:07
Show Gist options
  • Save warpgate3/d1d350d0f51a043ebca7da943d72703d to your computer and use it in GitHub Desktop.
Save warpgate3/d1d350d0f51a043ebca7da943d72703d to your computer and use it in GitHub Desktop.
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