Skip to content
Playground(another site)

bynk.http.form_on_sum_route

Error A @form handler's by clause is a sum of actors, whose wrapper reads the body as JSON itself.

A route by a sum of actors, such as User | Visitor, reads and verifies the request body as JSON itself. @form and @multipart have the router decode the body in another format, so the two cannot both own it and the pair is refused. Name one actor on the route, or split it into one route per actor. A route with @form and a second wire format is bynk.http.body_kind_conflict.

Example

type UserId = opaque String
type Search = { q: String }
actor User { auth = Bearer(secret = "AUTH_JWT_SECRET"), identity = UserId }
@form
on POST("/search") (body: Search) -> Effect[HttpResult[String]] by who: User | Visitor { … } // ✗ a sum of actors
@form
on POST("/search") (body: Search) -> Effect[HttpResult[String]] by who: User { … } // ✓ one actor

In the Book

See also

  • Every code in its category, HTTP, on the diagnostic index.
  • bynk explain bynk.http.form_on_sum_route shows the same from the installed toolchain, without a network.