/http-client

In this tutorial you will learn how to call a REST API using the JDK's Http Client. In this example you will call a public REST API and build out an entire CRUD service complete with tests using JUnit 5.

Primary LanguageJavaGNU Affero General Public License v3.0AGPL-3.0

Http-Client

In this tutorial you will learn how to call a REST API using the JDK's Http Client. In this example you will call a public REST API and build out an entire CRUD service complete with tests using JUnit 5.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Java 17 or higher
  • Maven
  • Docker (optional)
  • IntelliJ IDEA (optional)
  • Postman (optional)

Installing

A step by step series of examples that tell you how to get a development environment running.

  1. Clone the repository
git clone https://github.com/OmerJuve2023/http-client.git
  1. Change into the project directory
cd JpsOwnStarted
  1. Build the project
mvn clean install
  1. Run the project
mvn spring-boot:run
  1. Open your browser and navigate to http://localhost:8080/api/posts

Running the tests

To run the tests, execute the following command:

mvn test

Running the application with Docker

  1. Build the Docker image
docker build -t http-client
  1. Run the Docker container
docker run -p 8080:8080 http-client

Built With GraalVM

  1. Build the native image
mvn -Pnative spring-boot:build-image
  1. Run the native image
docker run -p 8080:8080 http-client

Authors