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

Function schemaBodyJson

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

Source from the content-addressed store, hash-verified

972 * @since 4.0.0
973 */
974export const schemaBodyJson = <S extends Schema.Constraint>(
975 schema: S,
976 options?: ParseOptions | undefined
977): {
978 (
979 body: S["Type"]
980 ): (
981 self: HttpClientRequest
982 ) => Effect.Effect<HttpClientRequest, HttpBody.HttpBodyError, S["EncodingServices"]>
983 (
984 self: HttpClientRequest,
985 body: S["Type"]
986 ): Effect.Effect<HttpClientRequest, HttpBody.HttpBodyError, S["EncodingServices"]>
987} => {
988 const encode = HttpBody.jsonSchema(schema, options)
989 return dual(
990 2,
991 (
992 self: HttpClientRequest,
993 body: unknown
994 ): Effect.Effect<HttpClientRequest, HttpBody.HttpBodyError, S["EncodingServices"]> =>
995 Effect.map(encode(body), (body) => setBody(self, body))
996 )
997}
998
999/**
1000 * 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