effect-http icon indicating copy to clipboard operation
effect-http copied to clipboard

Support handling FormData more like other request bodies

Open riwsky opened this issue 6 months ago • 4 comments

Add a new type parameter to ApiRequest, tracking the body type for the client creating the request. Add request-bodies setters that take both the server and client schemas. In the existing request-body setters, set the one given schema for both, matching existing behavior.

Add a Persisted schema alongside the FormData schema.

Add a formDataRequestBody convenience method, which calls setRequestBodies with Persisted for the server and FormData for the client.

Update the serverRequestParser to check for the Persisted schema, and implement that branch by grabbing the multipart from the HttpServerRequest. Leave around the FormData branch for backwards compatibility.

Update the form data test and example to use the new approach, taking the body in the callback arguments like the normal case.

riwsky avatar Aug 04 '24 19:08 riwsky