File tree 4 files changed +30
-3
lines changed
webflux-01-functional-approach
4 files changed +30
-3
lines changed Original file line number Diff line number Diff line change
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 `
Original file line number Diff line number Diff line change 11
11
12
12
@ Component
13
13
public class HelloHandler {
14
+ /**
15
+ * Serves a plain_text
16
+ *
17
+ * @param request
18
+ * @return
19
+ */
14
20
public Mono <ServerResponse > monoMessage (ServerRequest request ) {
15
21
return ServerResponse .ok ()
16
22
.contentType (MediaType .TEXT_PLAIN )
@@ -19,6 +25,12 @@ public Mono<ServerResponse> monoMessage(ServerRequest request) {
19
25
);
20
26
}
21
27
28
+ /**
29
+ * Serves a JSON stream
30
+ *
31
+ * @param request
32
+ * @return
33
+ */
22
34
public Mono <ServerResponse > fluxMessage (ServerRequest request ) {
23
35
return ServerResponse .ok ()
24
36
.contentType (MediaType .APPLICATION_STREAM_JSON )
Original file line number Diff line number Diff line change
1
+ server :
2
+ port : 8080
Original file line number Diff line number Diff line change @@ -17,9 +17,8 @@ public class FunctionalAppTest {
17
17
18
18
private final String TEST_MESSAGE = "Welcome to JstoBigdata.com" ;
19
19
20
-
21
20
@ Test
22
- public void testMonoEndpoint (){
21
+ public void testMonoEndpoint () {
23
22
Flux <String > msg$ = webTestClient .get ()
24
23
.uri ("/functional/mono" )
25
24
.accept (MediaType .TEXT_PLAIN )
@@ -34,7 +33,7 @@ public void testMonoEndpoint(){
34
33
}
35
34
36
35
@ Test
37
- public void testFluxEndpoint (){
36
+ public void testFluxEndpoint () {
38
37
Flux <String > msg$ = webTestClient .get ()
39
38
.uri ("/functional/flux" )
40
39
.accept (MediaType .APPLICATION_STREAM_JSON )
You can’t perform that action at this time.
0 commit comments