Open zhanjinhao opened 1 year ago
@Headers(value = {" content-type : application/x-www-form-urlencoded "})
jaxrs version: 3.0.7.Final feign version: 11.10
I want to use @FormParam to pass arguments, and this is my code :
server:
@POST @Path("/system/authentication/findGroupByUserName") List<Group> findGroupByUserName(@FormParam("username") String string);
client, service:
@POST @Path("/system/authentication/findGroupByUserName") @Headers(value = {" content-type : application/x-www-form-urlencoded "}) List<Group> findGroupByUserName(@FormParam("username") String string);
client feign builder:
Feign.builder() // required values .logger(new Slf4jLogger(type)) .client(new ApacheHttpClient(HttpClientUtils.getHttpClient())) .contract(new JAXRSContract()) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .options(options);
My JAXRSContract class is copy from feign-jaxrs peoject and I wrote some code so that it can parse the
@Headers
annotation. Now my issue is that the argument usename is encode to json instead of form. I have traced the code and found the code below : feign.jackson.JacksonEncoder#encodeThe data format of the form is: username = '123456', but the data format of the json is {"username":"123456"}. So how can i config the feign builder to make it work , or is there some other solutions.
Thanks !
Not sure that you need to copy JAXRSContract contract to support @Headers annotation. If you want to add content-type to the header you can use @Consumes annotation.
jaxrs version: 3.0.7.Final feign version: 11.10
I want to use @FormParam to pass arguments, and this is my code :
server:
client, service:
client feign builder:
My JAXRSContract class is copy from feign-jaxrs peoject and I wrote some code so that it can parse the
@Headers
annotation. Now my issue is that the argument usename is encode to json instead of form. I have traced the code and found the code below : feign.jackson.JacksonEncoder#encodeThe data format of the form is: username = '123456', but the data format of the json is {"username":"123456"}. So how can i config the feign builder to make it work , or is there some other solutions.
Thanks !