Skip to content

A light-weight library that brings a Fetch-like API to Java

License

Notifications You must be signed in to change notification settings

Insprill/fetch4j

Repository files navigation

Contributors Forks Stargazers Issues Apache 2.0 License

Fetch4J

A light-weight library that bring a Fetch-like API to Java.
View Javadocs »

Report Bug · Request Feature

Notice:
Fetch4J is now feature-complete. New features will only be added upon request. Bug fixes and maintenance will still be provided.

Table of Contents

  1. Usage
  2. Compiling
  3. Contributing
  4. License

Usage

Implementing in your project

Maven Central

Maven

<dependency>
    <groupId>net.insprill</groupId>
    <artifactId>fetch4j</artifactId>
    <version>version</version>
</dependency>

Gradle (Groovy)

dependencies {
    implementation 'net.insprill:fetch4j:version'
}

Gradle (Kotlin)

dependencies {
    implementation("net.insprill:fetch4j:version")
}

Common Usage

Simple GET

import static net.insprill.fetch4j.Fetch.fetch;

String body = fetch("https://example.com/").getBody();

Simple POST

import static net.insprill.fetch4j.Fetch.fetch;
import static net.insprill.fetch4j.Params.params;

Response response = fetch("https://example.com/api/paste", params()
        .method(Method.POST)
        .contentType(ContentType.TEXT)
        .body("Howdy"));

Advanced Usage

Fetch4J supports many parameters to customize requests. For all that are available, check out the Javadocs.

Compiling

To compile Fetch4J, you will need JDK 8 or higher and an internet connection.
Clone this repo, then run ./gradlew build from your terminal.
You can find the compiled jar in the build/libs directory.
If you wish to install it to your local Maven repository, run ./gradlew publishToMavenLocal.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create.
Any contributions you make are greatly appreciated!
If you're new to contributing to open-source projects, you can follow this guide.

License

Distributed under the Apache 2.0 License. See LICENSE for more information.