An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# feign-vertx

[![CI](https://github.com/OpenFeign/feign-vertx/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/OpenFeign/feign-vertx/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/hosuaby/vertx-feign/badge.svg?branch=master)](https://coveralls.io/github/hosuaby/vertx-feign?branch=master)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.openfeign/feign-vertx/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.openfeign/feign-vertx)
[![javadoc](https://javadoc.io/badge2/io.github.openfeign/feign-vertx/javadoc.svg)](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.