dew
Types
pub type DecodeError {
InvalidMethod
UnknownHeader
}
Constructors
-
InvalidMethod
-
UnknownHeader
pub type DecodedPacket {
BinaryData(HttpPacket, BitString)
EndOfHeaders(BitString)
MoreData(Option(Int))
}
Constructors
-
BinaryData(HttpPacket, BitString)
-
EndOfHeaders(BitString)
-
MoreData(Option(Int))
pub type HttpHandler =
fn(Request(BitString)) -> Response(BitString)
pub type HttpPacket {
HttpRequest(Atom, HttpUri, #(Int, Int))
HttpHeader(Int, Atom, BitString, BitString)
}
Constructors
-
HttpRequest(Atom, HttpUri, #(Int, Int))
-
HttpHeader(Int, Atom, BitString, BitString)
pub type PacketType {
Http
HttphBin
}
Constructors
-
Http
-
HttphBin
Functions
pub fn code_to_string(code: Int) -> String
pub fn from_header(value: BitString) -> String
pub fn hello_world(_msg: HandlerMessage, sock: Socket) -> Next(
Socket,
)
Just your standard hello_world
handler
pub fn http_response(status: Int, body: BitString) -> BitString
pub fn listen(port: Int, options: List(TcpOption)) -> Result(
ListenSocket,
SocketReason,
)
Re-exported from glisten
pub fn make_handler(handler: fn(Request(BitString)) ->
Response(BitString)) -> fn(HandlerMessage, Socket) ->
Next(Socket)
Convert your classic HTTP handler
into a TCP message handler.
You probably want to use this
pub fn parse_headers(bs: BitString, headers: List(
#(String, String),
)) -> Result(#(List(#(String, String)), BitString), DecodeError)
pub fn parse_request(bs: BitString) -> Result(
Request(BitString),
DecodeError,
)
Turns the TCP message into an HTTP request
pub fn start_acceptor_pool(listener_socket: ListenSocket, handler: fn(
HandlerMessage,
Socket,
) -> Next(Socket), pool_count: Int) -> Result(Nil, Nil)
Re-exported from glisten