Giter VIP home page Giter VIP logo

microprofile-rest-client's Introduction

microprofile rest client

Rest Client for MicroProfile

Rationale

The MicroProfile Rest Client provides a type-safe approach to invoke RESTful services over HTTP. As much as possible the MP Rest Client attempts to use JAX-RS 2.0 APIs for consistency and easier re-use.

Example

Here is an example - let’s say that you want to use a movie review service. The remote service might provide APIs to view users' reviews and allow you to post and modify your own reviews. You might start with an interface to represent the remote service like this:

 @Path("/movies")
 public interface MovieReviewService {
     @GET
     Set<Movie> getAllMovies();

     @GET
     @Path("/{movieId}/reviews")
     Set<Review> getAllReviews( @PathParam("movieId") String movieId );

     @GET
     @Path("/{movieId}/reviews/{reviewId}")
     Review getReview( @PathParam("movieId") String movieId, @PathParam("reviewId") String reviewId );

     @POST
     @Path("/{movieId}/reviews")
     String submitReview( @PathParam("movieId") String movieId, Review review );

     @PUT
     @Path("/{movieId}/reviews/{reviewId}")
     Review updateReview( @PathParam("movieId") String movieId, @PathParam("reviewId") String reviewId, Review review );
 }

Now we can use this interface as a means to invoke the actual remote review service like this:

URI apiUri = new URI("http://localhost:9080/movieReviewService");
MovieReviewService reviewSvc = RestClientBuilder.newBuilder()
            .baseUri(apiUri)
            .build(MovieReviewService.class);
Review review = new Review(3 /* stars */, "This was a delightful comedy, but not terribly realistic.");
reviewSvc.submitReview( movieId, review );

This allows for a much more natural coding style, and the underlying MicroProfile implementation handles the communication between the client and service - it makes the HTTP connection, serializes the Review object to JSON/XML/etc. so that the remote service can process it.

Implementations

This project only provides the specified API, a TCK and documentation. It does not provide an implementation. Various vendors are involved in this project and will provide their own implementation of this specification.

The following Implementations are available

Contributing

Do you want to contribute to this project? Find out how you can help here.

microprofile-rest-client's People

Contributors

adrianfiedler avatar andreas-eberle avatar andymc12 avatar asoldano avatar benjamin-confino avatar benjaminr-ps avatar cesarhernandezgt avatar derekm avatar eclipse-microprofile-bot avatar eclipsewebmaster avatar emily-jiang avatar gastaldi avatar gitter-badger avatar heiko-braun avatar jamezp avatar jgauravgupta avatar johnament avatar jwcarman avatar kenfinnigan avatar michalszynkiewicz avatar ondromih avatar pdudits avatar phillip-kruger avatar urbim avatar

Watchers

 avatar  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.