* Add new hugo-based website for hawkBit Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Fix broken links + wordings - , i.e. -> i.e, - , e.g. -> e.g., - hawkbit -> hawkBit - don't -> do not - isn't -> is not Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Remove old documentation and add maven integration Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Add Intellij files to ignore Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Update README Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Update Copyright header * exclude website artifacts Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Harmonize usage of i.e. and e.g. Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Add remark for windows user Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Fix indention Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Introduce review findings Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Change image in 'run hawkbit' guide Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com>
2.9 KiB
title, parent, weight
| title | parent | weight |
|---|---|---|
| Feign Client | Guides | 32 |
In this guide we describe how to create a Feign Rest Client based on a Spring Boot Application.
Create Feign REST Client
hawkBit provides REST interfaces for Management API and DDI API. Using this interfaces you can create a feign client with the help of the feign inheritance support. Our example modules demonstrate how to create Feign client resources. Here you can find the Management API client resources and the DDI client resources. A small simulator application demonstrates how you can interact with the hawkBit via the Management API .
Example Management API simulator
In the follow code section, you can a see a feign client resource example. The interface extend the origin api interface to declare the @FeignClient. The @FeignClientdeclares that a REST client with that interface should be created.
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
public interface MgmtTargetClientResource extends MgmtTargetRestApi {
}
This interface can be autowired and use as a normal java interface:
public class CreateStartedRolloutExample {
@Autowired
private MgmtTargetClientResource targetResource;
public void run() {
// create ten targets
targetResource.createTargets(new TargetBuilder().controllerId("00-FF-AA-0").name("00-FF-AA-0")
.description("Targets used for rollout example").buildAsList(10));
}
At hawkbit-example-core-feign-client is a spring configuration to auto configure some beans, which can be reused for a own feign client.
@Configuration
@ConditionalOnClass(Feign.class)
@Import(FeignClientsConfiguration.class)
public class FeignClientConfiguration {
@Bean
public ApplicationJsonRequestHeaderInterceptor jsonHeaderInterceptor() {
return new ApplicationJsonRequestHeaderInterceptor();
}
@Bean
public Contract feignContract() {
return new IgnoreMultipleConsumersProducersSpringMvcContract();
}
}