Skip to content

Instantly share code, notes, and snippets.

@predic8
Created February 7, 2018 14:45
Show Gist options
  • Save predic8/16a7a4cfd383e2cd9cbd3eb284fea24b to your computer and use it in GitHub Desktop.
Save predic8/16a7a4cfd383e2cd9cbd3eb284fea24b to your computer and use it in GitHub Desktop.
WebFlux Config
package de.predic8.reactiveweb;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.config.WebFluxConfigurer;
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;
import static org.springframework.web.reactive.function.BodyInserters.fromObject;
@Configuration
@EnableWebFlux
public class WebConfig implements WebFluxConfigurer {
@Bean
RouterFunction<ServerResponse> helloWorldRoute() {
return RouterFunctions.route(RequestPredicates.path("/hello"),
request -> ServerResponse.ok().body(fromObject("Hello World")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment