path
parameter based on the path's content.path
value is a relative path, it will be concatenated to the URL composed of the baseUrl
of the ChopperClient
and the baseUrl
of the enclosing service class (provided as a parameter of the @ChopperApi
annotation).ChopperClient
base URL: https://example.com/
Service base URL: profile
Path: /image
Result: https://example.com/profile/image​ChopperClient
base URL: https://example.com/
Service base URL: profile
Path: image
Result: https://example.com/profile/image​Chopper detects and handles missing slash (/
) characters on URL segment borders, but does not handle duplicate slashes.
baseUrl
concatenated with the request's path
results in a full URL, the ChopperClient
's baseUrl
is ignored.path
containing a full URL replaces the base URLs of both the ChopperClient
and the service class entirely for a request.ChopperClient
base URL: https://example.com/
Path: https://api.github.com/user
Result: https://api.github.com/user​ChopperClient
base URL: https://example.com/
Service base URL: profile
Path: https://api.github.com/user
Result: https://api.github.com/user​{
and }
. In the following example {id}
is a replacement block.@Path()
annotation to bind a parameter to a replacement block. This way the parameter's name must match a replacement block's string.@Path
annotation's name
parameter to match a replacement block's string while using a different parameter name, like in the following example:Chopper uses String interpolation to replace replacement blocks with the provided values in the request URLs.
@Query
annotation. Default values are supported.@Query
annotation is not set, Chopper will use the actual name of the annotated parameter as the key for the query parameter in the URL.Map
of query parameters, you can do so with the @QueryMap
annotation.@Body
annotation on a request method parameter to specify data that will be sent as the request's body.Object
s to Map
then JSON
.ChopperClient
for JSON conversion to happen. See built_value_converter for an example Converter implementation.Map<String, String>
object to the headers
parameter each of the HTTP verb annotations have.@Header
annotation can be used on method parameters to set headers dynamically for each request call.As Chopper invokes Interceptors and Converter(s) after creating a Request, Interceptors and Converters can override headers set with theheaders
parameter or@Header
annotations.
application/x-www-form-urlencoded
dataChopperClient
nor with the @FactoryConverter
annotation) and the request body is of type Map<String, String>
, the body will be sent as form URL encoded data.This is the default behavior of the http package.
FormUrlEncodedConverter
that will add the correct content-type
and convert a Map
into Map<String, String>
for requests.FormUrlEncodedConverter
's requestFactory
method with the @FactoryConverter
annotation.@Field
annotation on method parameters. If the field's name is not provided, the parameter's name is used as the field's name.