conversation
Types
A standard JavaScript Response
.
pub type JsResponse
The body of an incoming request. It must be read with functions like
read_text
, and can only be read once.
pub type RequestBody
Body type for an outgoing response.
import gleam/http/response
import conversation.{Text}
response.new(200)
|> response.set_body(Text("Hello, world!"))
pub type ResponseBody {
Text(String)
Bits(BitArray)
}
Constructors
-
Text(String)
-
Bits(BitArray)
Functions
pub fn read_bits(body: RequestBody) -> Promise(BitArray)
Read a request body as a BitArray.
pub fn read_json(body: RequestBody) -> Promise(Dynamic)
Read a request body as JSON, returning a
Dynamic
value
which can then be decoded with gleam_json
.
pub fn translate_request(req: JsRequest) -> Request(RequestBody)
pub fn translate_response(
res: Response(ResponseBody),
) -> JsResponse
Translates a Gleam Response
into a JsResponse
.