| 972 | * @since 4.0.0 |
| 973 | */ |
| 974 | export 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. |