Interface ResourceResponse

All Superinterfaces:
MetaCarrier

public interface ResourceResponse extends MetaCarrier
The result of a resources/read request.

Returning a ResourceResponse from a Resource or ResourceTemplate-annotated method gives more control over the response that's returned to the client.

  • Method Details

    • getContents

      List<ResourceContents> getContents()
      The resource contents. Usually a response will contain a single content object.
      Returns:
      the list of resource contents
    • builder

      static ResourceResponse.Builder builder()
      Create a builder for a ResourceResponse
      Returns:
      the new ResourceResponse builder
    • of

      static ResourceResponse of(String uri, String text)
      Creates a new ResourceResponse with text content and no MIME type
      Parameters:
      uri - the resource URI
      text - the text content
      Returns:
      the new resource response
    • of

      static ResourceResponse of(String uri, String text, String mimeType)
      Creates a new ResourceResponse with text content and MIME type
      Parameters:
      uri - the resource URI
      text - the text content
      mimeType - the MIME type
      Returns:
      the new resource response
    • of

      static ResourceResponse of(String uri, byte[] data)
      Creates a new ResourceResponse with binary content and no MIME type
      Parameters:
      uri - the resource URI
      data - the binary content
      Returns:
      the new resource response
    • of

      static ResourceResponse of(String uri, byte[] data, String mimeType)
      Creates a new ResourceResponse with binary content and MIME type
      Parameters:
      uri - the resource URI
      data - the binary content
      mimeType - the MIME type
      Returns:
      the new resource response