3232import org .springframework .http .server .reactive .HttpHandler ;
3333import org .springframework .http .server .reactive .ReactorHttpHandlerAdapter ;
3434import org .springframework .util .StringUtils ;
35- import org .springframework .web .reactive .function .RequestPredicates ;
36- import org .springframework .web .reactive .function .RouterFunction ;
37- import org .springframework .web .reactive .function .RouterFunctions ;
38- import org .springframework .web .reactive .function .ServerRequest ;
39- import org .springframework .web .reactive .function .ServerResponse ;
35+ import org .springframework .web .reactive .function .server . RequestPredicates ;
36+ import org .springframework .web .reactive .function .server . RouterFunction ;
37+ import org .springframework .web .reactive .function .server . RouterFunctions ;
38+ import org .springframework .web .reactive .function .server . ServerRequest ;
39+ import org .springframework .web .reactive .function .server . ServerResponse ;
4040
41- import static org .springframework .http . codec .BodyExtractors .toFlux ;
42- import static org .springframework .http . codec .BodyInserters .fromPublisher ;
41+ import static org .springframework .web . reactive . function .BodyExtractors .toFlux ;
42+ import static org .springframework .web . reactive . function .BodyInserters .fromPublisher ;
4343
4444import reactor .core .publisher .Flux ;
45+ import reactor .core .publisher .Mono ;
4546import reactor .ipc .netty .NettyContext ;
4647import reactor .ipc .netty .http .server .HttpServer ;
4748
@@ -72,7 +73,7 @@ public HttpHandler httpHandler(FunctionRegistry registry) {
7273 : registry .composeFunction (
7374 StringUtils .commaDelimitedListToStringArray (name ));
7475 FunctionInvokingHandler handler = new FunctionInvokingHandler (function );
75- RouterFunction <Publisher < String > > route = RouterFunctions .route (
76+ RouterFunction <ServerResponse > route = RouterFunctions .route (
7677 RequestPredicates .POST (webProperties .getPath ())
7778 .and (RequestPredicates .contentType (MediaType .TEXT_PLAIN )),
7879 handler ::handleText );
@@ -92,7 +93,7 @@ private FunctionInvokingHandler(Function<Flux<String>, Flux<String>> function) {
9293 this .function = function ;
9394 }
9495
95- private ServerResponse < Publisher < String > > handleText (ServerRequest request ) {
96+ private Mono < ServerResponse > handleText (ServerRequest request ) {
9697 Flux <String > input = request .body (toFlux (String .class ));
9798 Publisher <String > output = this .function .apply (input );
9899 return ServerResponse .ok ().body (fromPublisher (output , String .class ));
0 commit comments