MCPcopy Create free account
hub / github.com/Effect-TS/effect / schemaBodyJson

Function schemaBodyJson

packages/effect/src/unstable/http/HttpClientRequest.ts:734–757  ·  view source on GitHub ↗
(
  schema: S,
  options?: ParseOptions | undefined
)

Source from the content-addressed store, hash-verified

732 * @since 4.0.0
733 */
734export const schemaBodyJson = <S extends Schema.Constraint>(
735 schema: S,
736 options?: ParseOptions | undefined
737): {
738 (
739 body: S["Type"]
740 ): (
741 self: HttpClientRequest
742 ) => Effect.Effect<HttpClientRequest, HttpBody.HttpBodyError, S["EncodingServices"]>
743 (
744 self: HttpClientRequest,
745 body: S["Type"]
746 ): Effect.Effect<HttpClientRequest, HttpBody.HttpBodyError, S["EncodingServices"]>
747} => {
748 const encode = HttpBody.jsonSchema(schema, options)
749 return dual(
750 2,
751 (
752 self: HttpClientRequest,
753 body: unknown
754 ): Effect.Effect<HttpClientRequest, HttpBody.HttpBodyError, S["EncodingServices"]> =>
755 Effect.map(encode(body), (body) => setBody(self, body))
756 )
757}
758
759/**
760 * Sets an `application/x-www-form-urlencoded` request body from URL parameter input.

Callers

nothing calls this directly

Calls 2

encodeFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected