Interface HttpResponder

  • All Known Subinterfaces:
    HttpRequestContext

    public interface HttpResponder
    Defines method to respond HttpResponses.
    Since:
    1.1
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<HttpResult> respondBadRequestError​(java.lang.Throwable cause)
      Send HTTP response with "400 Bad Request Error" to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> respondError​(java.lang.Throwable cause)
      Respond HTTP error response to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> respondInternalServerError​(java.lang.Throwable cause)
      Send HTTP response with "500 Internal Server Error" to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> sendRedirect​(java.lang.CharSequence location)
      Send HTTP response with "302 Found" to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> sendRedirect​(java.lang.CharSequence location, java.util.function.Consumer<io.netty.handler.codec.http.HttpHeaders> addHeaders)
      Send HTTP response with "302 Found" to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> sendResponse​(io.netty.handler.codec.http.FullHttpResponse response)
      Send HTTP response to client and returns the HttpResultasynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> sendResponse​(io.netty.handler.codec.http.FullHttpResponse response, int contentLength)
      Send HTTP response to client and returns the HttpResultasynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(HttpFailureException cause)
      Respond a simple HTTP response with error message content to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(io.netty.handler.codec.http.HttpResponseStatus status)
      Respond a simple HTTP response without content to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.buffer.ByteBuf content, int contentLength, java.lang.CharSequence contentType)
      Respond a simple HTTP response with the specified content to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.buffer.ByteBuf content, java.lang.CharSequence contentType)
      Respond a simple HTTP response with the specified content to client and returns the HttpResult asynchronously.
      java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(io.netty.handler.codec.http.HttpResponseStatus status, java.util.function.Consumer<io.netty.handler.codec.http.HttpHeaders> addHeaders)
      Respond a simple HTTP response without content to client and returns the HttpResult asynchronously.
    • Method Detail

      • simpleRespond

        java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(io.netty.handler.codec.http.HttpResponseStatus status)
        Respond a simple HTTP response without content to client and returns the HttpResult asynchronously.
        Parameters:
        status - the status
        Returns:
        a CompletableFuture<HttpResult>
      • simpleRespond

        java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(io.netty.handler.codec.http.HttpResponseStatus status,
                                                                         java.util.function.Consumer<io.netty.handler.codec.http.HttpHeaders> addHeaders)
        Respond a simple HTTP response without content to client and returns the HttpResult asynchronously.
        Parameters:
        status - the status
        addHeaders - a function to add headers
        Returns:
        a CompletableFuture<HttpResult>
      • respondError

        java.util.concurrent.CompletableFuture<HttpResult> respondError​(java.lang.Throwable cause)
        Respond HTTP error response to client and returns the HttpResult asynchronously.
        Parameters:
        cause - the cause
        Returns:
        a CompletableFuture<HttpResult>
      • simpleRespond

        java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(HttpFailureException cause)
        Respond a simple HTTP response with error message content to client and returns the HttpResult asynchronously.
        Parameters:
        cause - a HttpFailureException
        Returns:
        a CompletableFuture<HttpResult>
      • simpleRespond

        java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(io.netty.handler.codec.http.HttpResponseStatus status,
                                                                         io.netty.buffer.ByteBuf content,
                                                                         java.lang.CharSequence contentType)
        Respond a simple HTTP response with the specified content to client and returns the HttpResult asynchronously.
        Parameters:
        status - the status
        content - the content
        contentType - the type of the content
        Returns:
        a CompletableFuture<HttpResult>
      • simpleRespond

        java.util.concurrent.CompletableFuture<HttpResult> simpleRespond​(io.netty.handler.codec.http.HttpResponseStatus status,
                                                                         io.netty.buffer.ByteBuf content,
                                                                         int contentLength,
                                                                         java.lang.CharSequence contentType)
        Respond a simple HTTP response with the specified content to client and returns the HttpResult asynchronously.
        Parameters:
        status - the status
        content - the content
        contentLength - the length of the content
        contentType - the type of the content
        Returns:
        a CompletableFuture<HttpResult>
      • respondBadRequestError

        java.util.concurrent.CompletableFuture<HttpResult> respondBadRequestError​(java.lang.Throwable cause)
        Send HTTP response with "400 Bad Request Error" to client and returns the HttpResult asynchronously.
        Parameters:
        cause - the cause
        Returns:
        a CompletableFuture<HttpResult>
      • respondInternalServerError

        java.util.concurrent.CompletableFuture<HttpResult> respondInternalServerError​(java.lang.Throwable cause)
        Send HTTP response with "500 Internal Server Error" to client and returns the HttpResult asynchronously.
        Parameters:
        cause - the cause
        Returns:
        a CompletableFuture<HttpResult>
      • sendResponse

        java.util.concurrent.CompletableFuture<HttpResult> sendResponse​(io.netty.handler.codec.http.FullHttpResponse response,
                                                                        int contentLength)
        Send HTTP response to client and returns the HttpResultasynchronously.
        Parameters:
        response - the FullHttpResponse
        contentLength - the length of the response body content
        Returns:
        a CompletableFuture<HttpResult>
      • sendResponse

        java.util.concurrent.CompletableFuture<HttpResult> sendResponse​(io.netty.handler.codec.http.FullHttpResponse response)
        Send HTTP response to client and returns the HttpResultasynchronously.
        Parameters:
        response - the FullHttpResponse
        Returns:
        a CompletableFuture<HttpResult>
      • sendRedirect

        java.util.concurrent.CompletableFuture<HttpResult> sendRedirect​(java.lang.CharSequence location)
        Send HTTP response with "302 Found" to client and returns the HttpResult asynchronously.
        Parameters:
        location - the location
        Returns:
        a CompletableFuture<HttpResult>
        Since:
        1.2
      • sendRedirect

        java.util.concurrent.CompletableFuture<HttpResult> sendRedirect​(java.lang.CharSequence location,
                                                                        java.util.function.Consumer<io.netty.handler.codec.http.HttpHeaders> addHeaders)
        Send HTTP response with "302 Found" to client and returns the HttpResult asynchronously.
        Parameters:
        location - the location
        addHeaders - a function to add headers
        Returns:
        a CompletableFuture<HttpResult>
        Since:
        1.2