org.springframework.web.reactive.function.server

Interface ServerResponse.BodyBuilder

    • Method Detail

      • body

        <T,P extends org.reactivestreams.Publisher<T>> reactor.core.publisher.Mono<ServerResponse> body(P publisher,
                                                                                                        java.lang.Class<T> elementClass)
        Set the body of the response to the given asynchronous Publisher and return it. This convenience method combines body(BodyInserter) and BodyInserters.fromPublisher(Publisher, Class).
        Type Parameters:
        T - the type of the elements contained in the publisher
        P - the type of the Publisher
        Parameters:
        publisher - the Publisher to write to the response
        elementClass - the class of elements contained in the publisher
        Returns:
        the built response
      • body

        <T,P extends org.reactivestreams.Publisher<T>> reactor.core.publisher.Mono<ServerResponse> body(P publisher,
                                                                                                        ParameterizedTypeReference<T> typeReference)
        Set the body of the response to the given asynchronous Publisher and return it. This convenience method combines body(BodyInserter) and BodyInserters.fromPublisher(Publisher, Class).
        Type Parameters:
        T - the type of the elements contained in the publisher
        P - the type of the Publisher
        Parameters:
        publisher - the Publisher to write to the response
        typeReference - a type reference describing the elements contained in the publisher
        Returns:
        the built response
      • syncBody

        reactor.core.publisher.Mono<ServerResponse> syncBody(java.lang.Object body)
        Set the body of the response to the given synchronous Object and return it. This convenience method combines body(BodyInserter) and BodyInserters.fromObject(Object).
        Parameters:
        body - the body of the response
        Returns:
        the built response
        Throws:
        java.lang.IllegalArgumentException - if body is a Publisher, for which body(Publisher, Class) should be used.
      • body

        reactor.core.publisher.Mono<ServerResponse> body(BodyInserter<?,? super ServerHttpResponse> inserter)
        Set the body of the response to the given BodyInserter and return it.
        Parameters:
        inserter - the BodyInserter that writes to the response
        Returns:
        the built response
      • render

        reactor.core.publisher.Mono<ServerResponse> render(java.lang.String name,
                                                           java.lang.Object... modelAttributes)
        Render the template with the given name using the given modelAttributes. The model attributes are mapped under a generated name.

        Note: Empty Collections are not added to the model when using this method because we cannot correctly determine the true convention name.

        Parameters:
        name - the name of the template to be rendered
        modelAttributes - the modelAttributes used to render the template
        Returns:
        the built response
      • render

        reactor.core.publisher.Mono<ServerResponse> render(java.lang.String name,
                                                           java.util.Map<java.lang.String,?> model)
        Render the template with the given name using the given model.
        Parameters:
        name - the name of the template to be rendered
        model - the model used to render the template
        Returns:
        the built response