Minor Changes
-
#3541
7041393
Thanks @tim-smart! - refactor /platform HttpClientHttpClient.fetch removed
The
HttpClient.fetch
client implementation has been removed. Instead, you can
access aHttpClient
using the correspondingContext.Tag
.import { FetchHttpClient, HttpClient } from "@effect/platform" import { Effect } from "effect" Effect.gen(function* () { const client = yield* HttpClient.HttpClient // make a get request yield* client.get("https://jsonplaceholder.typicode.com/todos/1") }).pipe( Effect.scoped, // the fetch client has been moved to the `FetchHttpClient` module Effect.provide(FetchHttpClient.layer) )
HttpClient
interface now uses methodsInstead of being a function that returns the response, the
HttpClient
interface now uses methods to make requests.Some shorthand methods have been added to the
HttpClient
interface to make
less complex requests easier.import { FetchHttpClient, HttpClient, HttpClientRequest } from "@effect/platform" import { Effect } from "effect" Effect.gen(function* () { const client = yield* HttpClient.HttpClient // make a get request yield* client.get("https://jsonplaceholder.typicode.com/todos/1") // make a post request yield* client.post("https://jsonplaceholder.typicode.com/todos") // execute a request instance yield* client.execute( HttpClientRequest.get("https://jsonplaceholder.typicode.com/todos/1") ) })
Scoped
HttpClientResponse
helpers removedThe
HttpClientResponse
helpers that also supplied theScope
have been removed.Instead, you can use the
HttpClientResponse
methods directly, and explicitly
add aEffect.scoped
to the pipeline.import { FetchHttpClient, HttpClient } from "@effect/platform" import { Effect } from "effect" Effect.gen(function* () { const client = yield* HttpClient.HttpClient yield* client.get("https://jsonplaceholder.typicode.com/todos/1").pipe( Effect.flatMap((response) => response.json), Effect.scoped // supply the `Scope` ) })
Some apis have been renamed
Including the
HttpClientRequest
body apis, which is to make them more
discoverable.
Patch Changes
-
#3541
812a4e8
Thanks @tim-smart! - add Logger.prettyLoggerDefault, to prevent duplicate pretty loggers -
#3541
6a128f6
Thanks @tim-smart! - ensure FetchHttpClient always attempts to send a request body -
#3541
adf7d7a
Thanks @tim-smart! - use Mailbox for Workers, Socket & Rpc -
#3541
e0d21a5
Thanks @fubhy! - Added refinement overloads toHttpClient.filterOrFail
andHttpClient.filterOrElse
-
Updated dependencies [
fcfa6ee
,bb9931b
,5798f76
,5f0bfa1
,7fdf9d9
,812a4e8
,273565e
,569a801
,aa1fa53
,02f6b06
,12b893e
,bbad27e
,adf7d7a
,007289a
,42a8f99
,eebfd29
,040703d
]:- effect@3.8.0
- @effect/schema@0.73.0