Project is under rebuild. It’s a hard fork of original HttpBuilder-NG
Version 1.* is fully compatible with original project HttpBuilder-NG but on upgraded stack. I.e. supports Groovy 4.* and is built with Java 17.
-
User Guide: https://http-builder-ng.github.io/http-builder-ng/asciidoc/html5/
-
JavaDocs: https://http-builder-ng.github.io/http-builder-ng/docs/javadoc/
-
Original Project : https://github.com/http-builder-ng/http-builder-ng
-
Current Project: https://github.com/katoquro/fg-net
-
StackOverflow: httpbuilder-ng
This is a modern Groovy DSL for making http requests. It is built against Groovy 4.x, but it doesn’t make any assumptions about which version of Groovy you are using (if they are compatible). The main goal of the client is to allow you to make http requests in a natural and readable way. For example:
//let's configure an http client to make calls to httpbin.org using the default http library
def httpBin = HttpBuilder.configure {
request.uri = 'http://httpbin.org/'
}
//now let's GET /get endpoint at httpbin.
//This will return a JSON formatted response with an origin property.
def result = httpBin.get {
request.uri.path = '/get'
}
println("Your ip address is: ${result.origin}")
//Finally lets post a standard http form to httpbin
httpBin.post {
request.uri.path = '/post'
request.body = [ input1: 'the first input', input2: 'the second input' ]
request.contentType = 'application/x-www-form-urlencoded'
}
Hopefully that gives you a general idea of how the client works. It is designed to be compatible with Groovy code annotated with @TypeChecked and @CompileStatic. It also makes use of the @DelegatesTo to provide better IDE support when writing code.
FG-Net artifacts are available on Maven Central, for Gradle you can add the following dependency to your build.gradle
file dependencies
closure:
implementation 'com.ainrif.fg-net:core:<version>'
or, for Maven add the following to your pom.xml
file:
<dependency>
<groupId>com.ainrif.fg-net</groupId>
<artifactId>core</artifactId>
<version>(version)</version>
</dependency>
Note
|
You can replace core with apache-provider and will be able to build clients this Apache Http Client.
|
HttpBuilder-NG is built using gradle. To perform a complete build run the following:
./gradlew clean build
-
configure
~/.gradle/gradle.properties
and importAinrif General GPG
. -
call
./gradlew clean build publishToSonatype closeAndReleaseSonatypeStagingRepository
to release lib. -
tag release commit with version
git tag <version from build.gradle> && git push --tags