A generic HTTP client for making RESTful API requests.
This client provides methods for performing standard HTTP operations (GET
, POST
, PUT
, DELETE
) and supports JSON encoding/decoding using Circe. Requests are constructed relative to the specified base URI, and responses are returned as effectful computations in the specified effect type.
Type parameters
- F
-
The effect type (e.g.,
IO
,Future
, etc.) that supports asynchronous and concurrent computations.
Value parameters
- baseUri
-
The base URI for all API requests made by this client.
- client
-
The underlying HTTP client instance used to send requests and receive responses.
Attributes
- Companion
- object
- Source
- HttpClient.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Decodes a JSON response into a specified type.
Decodes a JSON response into a specified type.
Attempts to decode the JSON string into the specified type using Circe. If decoding fails, this method raises an error with the failure details.
Type parameters
- T
-
The type to decode into, which must have an implicit Circe
Decoder
instance.
Value parameters
- response
-
The response body as a JSON string.
Attributes
- Returns
-
An effectful computation that yields the decoded value of type
T
. - Source
- HttpClient.scala
Sends an HTTP DELETE request.
Sends an HTTP DELETE request.
Constructs a DELETE request relative to the base URI and sends it to the specified endpoint.
Value parameters
- endpoint
-
The URI path of the endpoint to delete.
Attributes
- Returns
-
An effectful computation that yields the response body as a string.
- Source
- HttpClient.scala
Sends an HTTP GET request.
Sends an HTTP GET request.
Constructs a GET request relative to the base URI and sends it to the specified endpoint.
Value parameters
- endpoint
-
The URI path of the endpoint to query.
Attributes
- Returns
-
An effectful computation that yields the response body as a string.
- Source
- HttpClient.scala
Sends an HTTP POST request with a JSON payload.
Sends an HTTP POST request with a JSON payload.
Constructs a POST request relative to the base URI and sends it to the specified endpoint. The payload is serialised to JSON using Circe.
Type parameters
- T
-
The type of the payload, which must have an implicit Circe
Encoder
instance.
Value parameters
- endpoint
-
The URI path of the endpoint to send the request to.
- payload
-
The JSON payload to include in the request body.
Attributes
- Returns
-
An effectful computation that yields the response body as a string.
- Source
- HttpClient.scala
Sends an HTTP PUT request with a JSON payload.
Sends an HTTP PUT request with a JSON payload.
Constructs a PUT request relative to the base URI and sends it to the specified endpoint. The payload is serialised to JSON using Circe.
Type parameters
- T
-
The type of the payload, which must have an implicit Circe
Encoder
instance.
Value parameters
- endpoint
-
The URI path of the endpoint to send the request to.
- payload
-
The JSON payload to include in the request body.
Attributes
- Returns
-
An effectful computation that yields the response body as a string.
- Source
- HttpClient.scala
Implicits
Inherited implicits
Attributes
- Inherited from:
- Http4sClientDsl
- Source
- Http4sClientDsl.scala
Attributes
- Inherited from:
- Http4sClientDsl
- Source
- Http4sClientDsl.scala