| 732 | * @since 4.0.0 |
| 733 | */ |
| 734 | export 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. |