https://github.com/jeffgbutler/microservice-workshop-kotlin/
https://jeffgbutler.github.io/microservice-workshop-kotlin/
@EnableFeignClients
annotation on a configuration class
@FeignClient(name = "movie-award-service", url = "http://localhost:8083")
interface MovieAwardService {
@GetMapping("/award/search")
fun findAwardsForMovie(@RequestParam("movieId") movieId: Int): List
}
This will call a web service with a URL like http://localhost:8080/award/search?movieId=3
Returned JSON will be automatically unmarshalled to the class you define
@FeignClient(name = "movie-service", decode404 = true, url = "http://localhost:8081")
interface MovieService {
@GetMapping("/movie/{id}")
fun findById(@PathVariable("id") id: Int): Movie?
}
With decode404=true
the code will return null
if there is a 404 (NOT_FOUND) error
@FeignClient
are automatically discovered and available in the Spring
container@RestController
@FeignClient
Create Feign clients in the aggregate web service