howdy/content
What a response carries. Handlers return Response(Content), usually
built with controller.text, controller.json and friends.
response.new(200)
|> response.set_header("content-type", "text/csv")
|> response.set_body(content.Text(csv))
Types
The body of a response.
pub type Content {
Text(String)
Bytes(bytes_tree.BytesTree)
Empty
Native(Native)
}
Constructors
-
Text(String)Text, sent as UTF-8.
-
Bytes(bytes_tree.BytesTree)Raw bytes.
-
EmptyNo body at all.
-
Native(Native)A body only the server can send, such as a file from
howdy/static, a socket upgrade fromhowdy/websocket, a stream fromhowdy/sseor a body written in chunks byhowdy/stream. It cannot be built or read directly; middleware should pass it through unchanged.
Why something could not be sent on an open connection: a WebSocket frame, a server-sent event, or a chunk of a streamed body.
pub type SendError {
ConnectionClosed
StreamReset
SendTimedOut
SocketError(reason: String)
}
Constructors
-
ConnectionClosedThe client is gone, so nothing further can be written.
-
StreamResetThe client cancelled the HTTP/2 stream the response runs on.
-
SendTimedOutThe client stopped reading for long enough that the write gave up.
-
SocketError(reason: String)The socket refused the write for another reason, described by
reason.