Using Micronaut's HTTP client APIs
Micronaut's HTTP client is a non-blocking client based on Netty with baked-in cloud features such as service discovery and load balancing. This custom implementation enhances the standard HTTP client with microservices architecture.
To exhibit basic HTTP calls, we will create an HTTP client for OwnerResource
in the pet-owner
microservice. At the outset, we must have the micronaut-http-client
dependency in the pom.xml
project:
… <dependency> <groupId>io.micronaut</groupId> <artifactId>micronaut-http-client</artifactId> <scope>compile</scope> </dependency> …
micronaut-http-client
encapsulated all HTTP client-related APIs, such as creating RxHttpClient
, performing all HTTP operations, and handling and processing response payloads.
Next, we will explore how to leverage micronaut-http-client
to perform various HTTP operations on the endpoint we created earlier.