Skip to content
Playground(another site)

bynk.http.form_body_not_record

Error The body of a @form handler is not a record type.

@form and @multipart decode a form body one key at a time, into the fields of a record, so the body must be a record type. A String, a list or any other type has no fields for the keys to fill. Declare a record with one field per form key and take it as body; each field is then held to bynk.http.form_field_not_stringy. A JSON body of another shape needs no annotation.

Example

type Signup = { email: String }
@form
on POST("/signup") (body: String) -> Effect[HttpResult[String]] by v: Visitor { … } // ✗ a form decodes into a record
@form
on POST("/signup") (body: Signup) -> Effect[HttpResult[String]] by v: Visitor { … } // ✓

In the Book

See also

  • The grammar rule it governs: http_handler.
  • Every code in its category, HTTP, on the diagnostic index.
  • bynk explain bynk.http.form_body_not_record shows the same from the installed toolchain, without a network.