Spring 6 now supports creating HTTP clients using the @HttpExchange
annotation.
This removes the need for Spring Cloud OpenFeign.
The main goals of this project are:
- To promote
@HttpExchange
as the standard for defining API interfaces. - To offer an experience similar to
Spring Cloud OpenFeign
for declarative HTTP clients. - To ensure compatibility with Spring web annotations like
@RequestMapping
and@GetMapping
. - To avoid external annotations, making it easier to switch to other implementations.
implementation("io.github.danielliu1123:httpexchange-spring-boot-starter:<latest>")
@HttpExchange("https://my-json-server.typicode.com")
interface PostApi {
@GetExchange("/typicode/demo/posts/{id}")
Post getPost(@PathVariable("id") int id);
}
@SpringBootApplication
@EnableExchangeClients
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
@Bean
ApplicationRunner runner(PostApi api) {
return args -> api.getPost(1);
}
}
Refer to quick-start.
Go to Reference Documentation for more information.
This project is governed by the Code of Conduct. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to [email protected].
Use the issue tracker for bug reports, feature requests, and submitting pull requests.
If you would like to contribute to the project, please refer to Contributing.
The MIT License.
Many thanks to JetBrains for sponsoring this Open Source project with a license.