Skip to content

khouloudRouis/spring-boot-webclient-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Generic WebClient Utility

A small, production‑ready utility module for performing HTTP calls in Spring Boot applications using WebClient.
It is designed to be generic, reusable, and easy to integrate into existing services.

Features

  • Generic WebClient service: Centralized component for outbound HTTP calls.
  • HTTP method support: GET, POST, PUT, PATCH, and DELETE.
  • Simple integration: Drop into any Spring Boot project and wire via dependency injection.
  • Exception handling ready: Hooks for central error handling and custom exceptions.

Getting Started

  1. Add the module to your Spring Boot project (as a dependency or as source).
  2. Configure WebClient in WebClientConfiguration according to your environment (base URL, timeouts, interceptors, etc.).
  3. Inject GenericWebClientService into your services or controllers:
@Service
public class ExampleConsumerService {

    private final GenericWebClientService genericWebClientService;

    public ExampleConsumerService(GenericWebClientService genericWebClientService) {
        this.genericWebClientService = genericWebClientService;
    }

    public Mono<MyResponseDto> callExternalApi() {
        return genericWebClientService.get("/uri", MyResponseDto.class);
    }
}
  1. Handle errors using the provided ExternalApiException and GlobalExceptionHandler, or adapt them to your own error model.
  2. Api Base URL is configurable via application.properties

Technology Stack

  • Language: Java 21
  • Framework: Spring Boot 4.0.0
  • HTTP client: spring-boot-starter-webflux (WebClient)
  • Build tool: Maven

About

Spring Boot helper library providing common WebClient configurations such as timeouts, request/response logging, and error handling.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages