https://github.com/daggerok/reactive-spring
Awesome modern reactive non-blocking java web apps by using best framework ever!
https://github.com/daggerok/reactive-spring
spring-5 spring-boot spring-framework-5 spring-webflux webflux
Last synced: about 1 year ago
JSON representation
Awesome modern reactive non-blocking java web apps by using best framework ever!
- Host: GitHub
- URL: https://github.com/daggerok/reactive-spring
- Owner: daggerok
- License: mit
- Created: 2016-03-19T19:22:57.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-05-11T12:32:07.000Z (about 7 years ago)
- Last Synced: 2025-04-05T10:23:09.969Z (about 1 year ago)
- Topics: spring-5, spring-boot, spring-framework-5, spring-webflux, webflux
- Language: Java
- Homepage:
- Size: 229 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spring-webflux [](https://travis-ci.org/daggerok/reactive-spring)
modern reactive and non-blocking java web apps
```java
@Component
class ApplicationHandlers {
/** Functional rendering thymeleaf template */
Mono index(final ServerRequest request) {
return create("index").modelAttribute("message", "Hello, World!")
.build()
;
}
/*// same index rendering...
Mono index(final ServerRequest request) {
return ok().contentType(TEXT_HTML)
.render("index", singletonMap("message", "Hello, World!"))
;
}
*/
/** Functional webflux REST API endpoint */
Mono api(final ServerRequest request) {
return ok().contentType(APPLICATION_JSON_UTF8)
.body(Mono.just("Hello World!"), String.class)
;
}
}
@Configuration
@EnableWebFlux
public class Application {
@Bean
RouterFunction routes(final ApplicationHandlers handlers) {
return route(GET("/api/**").and(accept(APPLICATION_JSON_UTF8)), handlers::api)
.andOther(route(GET("/").and(accept(TEXT_HTML)), handlers::index))
;
}
}
```