Skip to content
Playground(another site)

bynk.http.stream_body_on_sum_route

Error A route with a streamed body has a by clause that is a sum of actors, whose wrapper reads the body itself.

A route by a sum of actors, such as User | Visitor, reads and verifies the request body itself before the handler runs. A streamed body is not read until the handler pulls it, 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.

Example

actor User { auth = Bearer(secret = "AUTH_JWT_SECRET"), identity = UserId }
@raw(contentType: "image/png")
@limit(maxBody: 5_000_000)
on PUT("/avatars") (body: Stream[Bytes]) -> Effect[HttpResult[()]] by who: User | Visitor { … } // ✗ a sum of actors
@raw(contentType: "image/png")
@limit(maxBody: 5_000_000)
on PUT("/avatars") (body: Stream[Bytes]) -> Effect[HttpResult[()]] by who: User { … } // ✓ one actor

In the Book

See also

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