Skip to content
Playground(another site)

bynk.http.query_wrong_type

Error An HTTP handler's query parameter is neither a record type nor RequestQuery.

A handler's query parameter is the request's query string, and the router offers two ways to take it: a record type, which it decodes and validates, answering 400 when the string does not fit, or RequestQuery, the raw view. Any other type is refused. Declare the keys you expect as a record, or take RequestQuery. The record's fields are held to bynk.http.query_field_not_stringy.

Example

on GET("/items") (query: String) -> Effect[HttpResult[String]] by v: Visitor { … } // ✗ `query` is a record or `RequestQuery`
type Filter = { tag: Option[String] }
on GET("/items") (query: Filter) -> 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.query_wrong_type shows the same from the installed toolchain, without a network.