Interface MutableHttpResponse<B>

  • Type Parameters:
    B - The body response type
    All Superinterfaces:
    io.micronaut.core.attr.AttributeHolder, HttpMessage<B>, HttpResponse<B>, io.micronaut.core.attr.MutableAttributeHolder, MutableHttpMessage<B>

    public interface MutableHttpResponse<B>
    extends HttpResponse<B>, MutableHttpMessage<B>
    A version of the HttpResponse interface that is mutable allowing the ability to set headers, character encoding etc.
    Since:
    1.0
    • Method Detail

      • cookie

        MutableHttpResponse<B> cookie​(Cookie cookie)
        Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.
        Parameters:
        cookie - the Cookie to return to the client
        Returns:
        This response object
      • cookies

        default MutableHttpResponse<B> cookies​(java.util.Set<Cookie> cookies)
        Adds the specified cookies to the response.
        Parameters:
        cookies - the Set of Cookies to return to the client
        Returns:
        This response object
      • body

        <T> MutableHttpResponse<T> body​(@Nullable
                                        T body)
        Sets the body.
        Specified by:
        body in interface MutableHttpMessage<B>
        Type Parameters:
        T - The new body type
        Parameters:
        body - The body
        Returns:
        This response object
      • status

        MutableHttpResponse<B> status​(HttpStatus status,
                                      java.lang.CharSequence message)
        Sets the response status.
        Parameters:
        status - The status
        message - The message
        Returns:
        This response object
      • header

        default MutableHttpResponse<B> header​(java.lang.CharSequence name,
                                              java.lang.CharSequence value)
        Description copied from interface: MutableHttpMessage
        Set a response header.
        Specified by:
        header in interface MutableHttpMessage<B>
        Parameters:
        name - The name of the header
        value - The value of the header
        Returns:
        This response
      • headers

        default MutableHttpResponse<B> headers​(java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> namesAndValues)
        Description copied from interface: MutableHttpMessage
        Set multiple headers.
        Specified by:
        headers in interface MutableHttpMessage<B>
        Parameters:
        namesAndValues - The names and values
        Returns:
        This response
      • characterEncoding

        default MutableHttpResponse<B> characterEncoding​(java.lang.CharSequence encoding)
        Sets the response encoding. Should be called after contentType(MediaType).
        Parameters:
        encoding - The encoding to use
        Returns:
        This response object
      • characterEncoding

        default MutableHttpResponse<B> characterEncoding​(java.nio.charset.Charset encoding)
        Sets the response encoding.
        Parameters:
        encoding - The encoding to use
        Returns:
        The encoded reponse object
      • locale

        default MutableHttpResponse<B> locale​(java.util.Locale locale)
        Sets the locale to use and will apply the appropriate HttpHeaders.CONTENT_LANGUAGE header to the response.
        Parameters:
        locale - The locale
        Returns:
        This response object
      • status

        default MutableHttpResponse<B> status​(int status)
        Sets the response status.
        Parameters:
        status - The status
        Returns:
        This response object
      • status

        default MutableHttpResponse<B> status​(int status,
                                              java.lang.CharSequence message)
        Sets the response status.
        Parameters:
        status - The status
        message - The message
        Returns:
        This response object
      • status

        default MutableHttpResponse<B> status​(HttpStatus status)
        Sets the response status.
        Parameters:
        status - The status
        Returns:
        This response object
      • attribute

        default MutableHttpResponse<B> attribute​(java.lang.CharSequence name,
                                                 java.lang.Object value)
        Sets an attribute on the response.
        Parameters:
        name - The attribute name
        value - The attribute value
        Returns:
        This response object