Class AbstractRestChannel

  • All Implemented Interfaces:
    RestChannel

    public abstract class AbstractRestChannel
    extends java.lang.Object
    implements RestChannel
    • Field Detail

      • detailedErrorsEnabled

        protected final boolean detailedErrorsEnabled
    • Constructor Detail

      • AbstractRestChannel

        protected AbstractRestChannel​(RestRequest request,
                                      boolean detailedErrorsEnabled)
        Construct a channel for handling the request.
        Parameters:
        request - the request
        detailedErrorsEnabled - if detailed errors should be reported to the channel
        Throws:
        java.lang.IllegalArgumentException - if parsing the pretty or human parameters fails
    • Method Detail

      • newBuilder

        public XContentBuilder newBuilder​(@Nullable
                                          XContentType requestContentType,
                                          boolean useFiltering)
                                   throws java.io.IOException
        Creates a new XContentBuilder for a response to be sent using this channel. The builder's type is determined by the following logic. If the request has a format parameter that will be used to attempt to map to an XContentType. If there is no format parameter, the HTTP Accept header is checked to see if it can be matched to a XContentType. If this first attempt to map fails, the request content type will be used if the value is not null; if the value is null the output format falls back to JSON.
        Specified by:
        newBuilder in interface RestChannel
        Throws:
        java.io.IOException
      • bytesOutput

        public final BytesStreamOutput bytesOutput()
        A channel level bytes output that can be reused. The bytes output is lazily instantiated by a call to newBytesOutput(). Once the stream is created, it gets reset on each call to this method.
        Specified by:
        bytesOutput in interface RestChannel
      • bytesOutputOrNull

        protected final BytesStreamOutput bytesOutputOrNull()
        An accessor to the raw value of the channel bytes output. This method will not instantiate a new stream if one does not exist and this method will not reset the stream.
      • detailedErrorsEnabled

        public boolean detailedErrorsEnabled()
        Specified by:
        detailedErrorsEnabled in interface RestChannel
        Returns:
        true iff an error response should contain additional details like exception traces.