Skip to content

DanielLiu1123/httpexchange-spring-boot-starter

Repository files navigation

HttpExchange Spring Boot Starter Build Maven Central License: MIT

Spring 6 now natively supports creating HTTP clients using the @HttpExchange annotation. This eliminates the need for Spring Cloud OpenFeign.

The primary goals of this project are:

  • Advocate for the use of @HttpExchange as a standard annotation for defining API interfaces.
  • Deliver a Spring Cloud OpenFeign-like experience for Spring 6 declarative HTTP clients.
  • Ensure compatibility with Spring web annotations such as (@RequestMapping, @GetMapping).
  • Avoid introducing external annotations, making it easy to migrate to other implementations.

Quick Start

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.

Documentation

Go to Reference Documentation for more information.

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 llw599502537@gmail.com.

Contributing

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.

License

The MIT License.

Special Thanks

Many thanks to JetBrains for sponsoring this Open Source project with a license.