retrofit / retrofit2.http / HTTP

HTTP

@Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) class HTTP

Use a custom HTTP verb for a request.


  interface Service {
    @HTTP(method = "CUSTOM", path = "custom/endpoint/")
    Call<ResponseBody> customEndpoint();
  }
  
This annotation can also used for sending DELETE with a request body:

  interface Service {
    @HTTP(method = "DELETE", path = "remove/", hasBody = true)
    Call<ResponseBody> deleteObject(@Body RequestBody object);
  }
  

Constructors

<init>

HTTP(method: String, path: String, hasBody: Boolean)

Use a custom HTTP verb for a request.


  interface Service {
    @HTTP(method = "CUSTOM", path = "custom/endpoint/")
    Call<ResponseBody> customEndpoint();
  }
  
This annotation can also used for sending DELETE with a request body:

  interface Service {
    @HTTP(method = "DELETE", path = "remove/", hasBody = true)
    Call<ResponseBody> deleteObject(@Body RequestBody object);
  }
  

Properties

hasBody

val hasBody: Boolean

method

val method: String

path

val path: String

A relative or absolute path, or full URL of the endpoint. This value is optional if the first parameter of the method is annotated with @Url.