Interface Endpoint<RequestT,ResponseT,ErrorT>

Type Parameters:
RequestT - the endpoint's request
ResponseT - the endpoint's response. Use Void when there's no response body.
ErrorT - the endpoint's error type. Use Void when error responses have no body.
All Known Subinterfaces:
JsonEndpoint<RequestT,ResponseT,ErrorT>
All Known Implementing Classes:
BinaryEndpoint, BooleanEndpoint, DelegatingJsonEndpoint, EndpointBase, EndpointWithResponseMapperAttr, SimpleEndpoint, SimpleJsonEndpoint

public interface Endpoint<RequestT,ResponseT,ErrorT>
An endpoint links requests and responses to HTTP protocol encoding. It also defines the error response when the server cannot perform the request.

Requests are serialized as JSON by default, unless they implement specific marker interfaces that indicate otherwise and must be handled by the transport processing the request (e.g. NdJsonpSerializable).

Response body decoding, when applicable, is defined by child interfaces like JsonEndpoint.

  • Method Details

    • id

      String id()
      The endpoint's identifier.
    • method

      String method(RequestT request)
      Get the endpoint's HTTP method for a request.
    • requestUrl

      String requestUrl(RequestT request)
      Get the URL path for a request.
    • queryParameters

      default Map<String,String> queryParameters(RequestT request)
      Get the query parameters for a request.
    • headers

      default Map<String,String> headers(RequestT request)
      Get the HTTP headers for a request.
    • body

      @Nullable Object body(RequestT request)
      Get the body for a request. The caller must handle several cases depending on the interface implemented by the result:
    • null means the request has no body.
    • NdJsonpSerializable must be serialized as nd-json.
    • BinaryData must be serialized as is.
    • All other objects must be serialized as JSON using a JsonpMapper
    • isError

      boolean isError(int statusCode)
      Is this status code to be considered as an error?
    • errorDeserializer

      @Nullable JsonpDeserializer<ErrorT> errorDeserializer(int statusCode)
      The entity parser for the error response body. Can be null to indicate that there's no error body.
    • withBinaryResponse

      default BinaryEndpoint<RequestT> withBinaryResponse()