public class FormEncoder extends Object implements feign.codec.Encoder
Also, the encoder has a delegate field for encoding non-form requests (like JSON or other).
Default delegate object is Encoder.Default
instance.
Usage example:
Declaring API interface:
interface SomeApi { @RequestLine("POST /json") @Headers("Content-Type: application/json") void json (Dto dto); @RequestLine("POST /form") @Headers("Content-Type: application/x-www-form-urlencoded") void from (@Param("field1") String field1, @Param("field2") String field2); }
Creating Feign client instance:
SomeApi api = Feign.builder() .encoder(new FormEncoder(new JacksonEncoder())) .target(SomeApi.class, "http://localhost:8080");
Now it can handle JSON Content-Type by feign.jackson.JacksonEncoder
and
form request by FormEncoder
.
Constructor and Description |
---|
FormEncoder()
Default
FormEncoder constructor. |
FormEncoder(feign.codec.Encoder delegate)
FormEncoder constructor with delegate encoder argument. |
Modifier and Type | Method and Description |
---|---|
void |
encode(Object object,
Type bodyType,
feign.RequestTemplate template) |
public FormEncoder()
FormEncoder
constructor.
Sets Encoder.Default
instance as delegate encoder.
public FormEncoder(feign.codec.Encoder delegate)
FormEncoder
constructor with delegate encoder argument.
delegate
- delegate encoder for processing non-form requests.Copyright © 2016 Pivotal Software, Inc.. All rights reserved.