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:
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-httplibrary does not includejersey-clientas compile time dependency, thus you need to include it asprovidedscope.
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
- Mihai for nice writeup!
- jcabi-http
- Xiaoying Riley - This documentation theme is referred from here
- bootstrap toc