https://github.com/openfeign/feign-vertx
Use Feign on Vert.x
https://github.com/openfeign/feign-vertx
Last synced: 6 months ago
JSON representation
Use Feign on Vert.x
- Host: GitHub
- URL: https://github.com/openfeign/feign-vertx
- Owner: OpenFeign
- License: apache-2.0
- Created: 2016-08-23T08:29:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-07-14T15:45:29.000Z (over 1 year ago)
- Last Synced: 2024-07-15T15:38:11.942Z (over 1 year ago)
- Language: Java
- Size: 137 KB
- Stars: 54
- Watchers: 5
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# feign-vertx
[](https://github.com/OpenFeign/feign-vertx/actions/workflows/ci.yml)
[](https://coveralls.io/github/hosuaby/vertx-feign?branch=master)
[](https://maven-badges.herokuapp.com/maven-central/io.github.openfeign/feign-vertx)
[](https://javadoc.io/doc/io.github.openfeign/feign-vertx)
Implementation of Feign on Vertx. Brings you the best of two worlds together :
concise syntax of Feign to write client side API on fast, asynchronous and
non-blocking HTTP client of Vertx.
## Installation
### With Maven
```xml
...
io.github.openfeign
feign-vertx
6.0.1
...
```
### With Gradle
```groovy
compile group: 'io.github.openfeign', name: 'feign-vertx', version: '6.0.1'
```
## Compatibility
Feign | feign-vertx | Vertx
---------------------- |-------------| ----------------------
8.x | 1.x+ | 3.5.x - 3.9.x (except 3.5.2)
9.x | 2.x+ | 3.5.x - 3.9.x (except 3.5.2)
10.x (except 10.5.0) | 3.x+ | 3.5.x - 3.9.x (except 3.5.2)
11.x | 4.x+ | 3.5.x - 3.9.x (except 3.5.2)
11.x | 5.x+ | 4.x
12.x | unsupported |
13.x | 6.x+ | 4.x
## Usage
Write Feign API as usual, but every method of interface must return
`io.vertx.core.Future`.
```java
@Headers({ "Accept: application/json" })
interface IcecreamServiceApi {
@RequestLine("GET /icecream/flavors")
Future> getAvailableFlavors();
@RequestLine("GET /icecream/mixins")
Future> getAvailableMixins();
@RequestLine("POST /icecream/orders")
@Headers("Content-Type: application/json")
Future makeOrder(IceCreamOrder order);
@RequestLine("GET /icecream/orders/{orderId}")
Future findOrder(@Param("orderId") int orderId);
@RequestLine("POST /icecream/bills/pay")
@Headers("Content-Type: application/json")
Future payBill(Bill bill);
}
```
Build the client :
```java
Vertx vertx = Vertx.vertx(); // get Vertx instance
/* Create instance of your API */
IcecreamServiceApi icecreamApi = VertxFeign
.builder()
.vertx(vertx) // provide vertx instance
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.target(IcecreamServiceApi.class, "http://www.icecreame.com");
/* Execute requests asynchronously */
Future> flavorsFuture = icecreamApi.getAvailableFlavors();
Future> mixinsFuture = icecreamApi.getAvailableMixins();
```
## License
Library distributed under Apache License Version 2.0.