Git Product home page Git Product logo

feign-vertx's Introduction

feign-vertx

CI Coverage Status Maven Central javadoc

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

<dependencies>
    ...
    <dependency>
        <groupId>io.github.openfeign</groupId>
        <artifactId>feign-vertx</artifactId>
        <version>5.0.0</version>
    </dependency>
    ...
</dependencies>

With Gradle

compile group: 'io.github.openfeign', name: 'feign-vertx', version: '5.0.0'

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.0.x

Usage

Write Feign API as usual, but every method of interface must return io.vertx.core.Future.

@Headers({ "Accept: application/json" })
interface IcecreamServiceApi {

  @RequestLine("GET /icecream/flavors")
  Future<Collection<Flavor>> getAvailableFlavors();

  @RequestLine("GET /icecream/mixins")
  Future<Collection<Mixin>> getAvailableMixins();

  @RequestLine("POST /icecream/orders")
  @Headers("Content-Type: application/json")
  Future<Bill> makeOrder(IceCreamOrder order);

  @RequestLine("GET /icecream/orders/{orderId}")
  Future<IceCreamOrder> findOrder(@Param("orderId") int orderId);
  
  @RequestLine("POST /icecream/bills/pay")
  @Headers("Content-Type: application/json")
  Future<Void> payBill(Bill bill);
}

Build the client :

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<Collection<Flavor>> flavorsFuture = icecreamApi.getAvailableFlavors();
Future<Collection<Mixin>> mixinsFuture = icecreamApi.getAvailableMixins();

License

Library distributed under Apache License Version 2.0.

feign-vertx's People

Contributors

adriancole avatar garyschulteog avatar gordonmckinney avatar hosuaby avatar jlleitschuh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.