Build Status codecov Codacy Badge


Introduction

In my blog I have introduced about aws-http library.

Usage

Include your maven or gradle project as below:

maven:


        <dependency>           
        <groupId>io.github.rishikeshdarandale</groupId>
        <artifactId>aws-http</artifactId>
        <version>1.0.1</version>
        </dependency>
      

gradle:


        dependencies {
          compile 'io.github.rishikeshdarandale:aws-http:1.0.1'
        }
      

A simple use of the library shown below:


        MyClass myClassObject = new JdkRequest("https://www.somehost.com")
              .method(RequestMethod.GET)
              .path("/mypath")
              .queryParams("message", "hello*world")
              .header("Accept", "application/json")
              .header("Content-Type", "application/json")
              .body("{}")
              .sign(AwsSignParams("myAccessKey", "MySecretId", "es"))
              .execute()
              .getAs(MyClass.class);
      

SNAPSHOT latest version

One can find the latest code with SNAPSHOT version in snapshot artifactory


        <repositories>
          <repository>
            <id>oss.sonatype.org</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
          </repository>
        </repositories>
      

Documentation

The documentation and latest release version is mentioned below:

Maven Central Javadocs


More Examples

Getting response as a String:


        String body = new JdkRequest("https://www.somehost.com")
              .method(RequestMethod.GET)
              .path("/mypath")
              .queryParams("message", "hello*world")
              .header("Accept", "application/json")
              .header("Content-Type", "application/json")
              .body("{}")
              .sign(AwsSignParams("myAccessKey", "MySecretId", "es"))
              .execute()
              .body();
      

Using with Jersey Client

Include the jersey-client library along with aws-http library.


        <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.26</version>
        </dependency>
      
aws-http library does not include jersey-client as compile time dependency, thus you need to include it as provided scope.

        String body = new JerseyRequest("https://www.somehost.com")
              .method(RequestMethod.GET)
              .path("/mypath")
              .queryParams("message", "hello*world")
              .header("Accept", "application/json")
              .header("Content-Type", "application/json")
              .body("{}")
              .sign(AwsSignParams("myAccessKey", "MySecretId", "es"))
              .execute()
              .body();
      

Credits