httpexchange-spring-boot-starter
httpexchange-spring-boot-starter copied to clipboard
The missing starter for Spring 6 declarative HTTP client (@HttpExchange).
HttpExchange Spring Boot Starter
Spring 6 now directly supports creating HTTP clients with the @HttpExchange
annotation.
This means you can use Spring instead of needing Spring Cloud OpenFeign.
The main goals of this project:
- Promote the use of
@HttpExchange
as a neutral annotation to define API interfaces. - Provide a
Spring Cloud OpenFeign
like experience for Spring 6 declarative HTTP clients. - Support Spring web annotations (
@RequestMapping
,@GetMapping
). - Not introduce external annotations, easy to migrate to other implementations.
Quick Start
-
Add dependency:
implementation("io.github.danielliu1123:httpexchange-spring-boot-starter:3.2.5")
-
Write a classic Spring Boot application:
@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); } }
Documentation
Go to Documentation to view the full documentation.
Version Compatibility
Spring Boot | httpexchange-spring-boot-starter |
---|---|
3.2.x | 3.2.5 |
3.1.x | 3.1.8 |
Code of Conduct
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].
Contributing
The issue tracker is the preferred channel for bug reports, feature requests and submitting pull requests.
If you would like to contribute to the project, please refer to Contributing.
License
The MIT License.
Special Thanks
Many thanks to JetBrains for sponsoring this Open Source project with a license.