java-tutorials/kdoyle/ReadingController.java

19 lines
544 B
Java
Raw Normal View History

2018-05-02 00:18:41 -04:00
package com.baeldung.reactive.kdoyle;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import java.util.stream.Stream;
@RestController
public class ReadingController {
@GetMapping(produces = MediaType.TEXT_EVENT_STREAM_VALUE, value = "/read")
public Flux<ReadingBook> getWord(){
return Flux.fromStream(Stream.generate(() -> new ReadingBook()));
}
}