Issue with overriding default headers in HttpClient setup using mapRequestInput

I'm using the HttpClient platform and I'm trying to have the following effect:
1. When my custom client is initialized, it has some default headers appended to it.
2. I have a function that then allows you to override the client's default headers.

The below doesn't seem to remap the headers and I'm unsure why as the annotation for: "mapRequestInput" says it "Prepends a transformation of the request object before sending it"

Am I doing something wrong or rather is there a better way of doing this?

import {Effect} from "effect";
import {HttpClient, HttpClientRequest} from "effect/platform";

export class MyCustomClient extends Effect.Service<MyCustomClient >()(
  "@example/MyCustomClient",
  {
    effect: Effect.gen(function*(){
      const defaultClient = yield* HttpClient.HttpClient;
      
      const client = defaultClient.pipe(
        HttpClient.mapRequestInput(
          request => request.pipe(
            HttpClientRequest.setHeaders({
              "Wow": "testing"
            })
          )
        )
      )

      type Options = {headers: Record<string, string>}

      const makeRequest = (options?: Options) => HttpClientRequest.get("https://example.com").pipe(
      HttpClientRequest.setHeaders({
        ...(options?.headers || {}),
        "Wow": "This should override"
      })
    )

      return {
        fetch: (options: Options) => Effect.gen(function*(){
           return yield* client.execute(makeRequest(options))
        })
      }
    })
  }
){}
Was this page helpful?