Skip to content

Commit 72192ae

Browse files
committedJul 10, 2020
1 parent aa10b0a commit 72192ae

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed
 
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
1. To run the application
2+
```shell script
3+
mvn spring-boot:run
4+
```
5+
6+
2. Visit the below urls in a browser:
7+
```
8+
http://localhost:8080/functional/mono
9+
```
10+
11+
```
12+
http://localhost:8080/functional/flux
13+
```
14+
3. If needed, change the app-server #port in `src/main/resources/application.yml`

‎webflux-01-functional-approach/src/main/java/c/jbd/webflux/HelloHandler.java

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
@Component
1313
public class HelloHandler {
14+
/**
15+
* Serves a plain_text
16+
*
17+
* @param request
18+
* @return
19+
*/
1420
public Mono<ServerResponse> monoMessage(ServerRequest request) {
1521
return ServerResponse.ok()
1622
.contentType(MediaType.TEXT_PLAIN)
@@ -19,6 +25,12 @@ public Mono<ServerResponse> monoMessage(ServerRequest request) {
1925
);
2026
}
2127

28+
/**
29+
* Serves a JSON stream
30+
*
31+
* @param request
32+
* @return
33+
*/
2234
public Mono<ServerResponse> fluxMessage(ServerRequest request) {
2335
return ServerResponse.ok()
2436
.contentType(MediaType.APPLICATION_STREAM_JSON)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
server:
2+
port: 8080

‎webflux-01-functional-approach/src/test/java/c/jbd/webflux/FunctionalAppTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ public class FunctionalAppTest {
1717

1818
private final String TEST_MESSAGE = "Welcome to JstoBigdata.com";
1919

20-
2120
@Test
22-
public void testMonoEndpoint(){
21+
public void testMonoEndpoint() {
2322
Flux<String> msg$ = webTestClient.get()
2423
.uri("/functional/mono")
2524
.accept(MediaType.TEXT_PLAIN)
@@ -34,7 +33,7 @@ public void testMonoEndpoint(){
3433
}
3534

3635
@Test
37-
public void testFluxEndpoint(){
36+
public void testFluxEndpoint() {
3837
Flux<String> msg$ = webTestClient.get()
3938
.uri("/functional/flux")
4039
.accept(MediaType.APPLICATION_STREAM_JSON)

0 commit comments

Comments
 (0)
Please sign in to comment.