Represents an HTTP connection in Passby.
This struct and its helper functions provide a familiar, lightweight API
compatible with Plug.Conn and Bypass handler functions without requiring
Plug as a dependency.
Summary
Functions
Gets the values of the specified request header.
Sets or adds a response header.
Sets the response status and body without immediately transmitting it.
Sends the response configured in the connection struct over the socket.
Sends the response with the given status and body over the underlying socket.
Types
@type t() :: %Passby.Conn{ adapter: {module(), any()}, method: String.t(), path_info: [String.t()], query_string: String.t(), req_body: binary(), req_headers: [{String.t(), String.t()}], request_path: String.t(), resp_body: binary() | nil, resp_headers: [{String.t(), String.t()}], state: :unset | :set | :sent, status: integer() | nil }
Functions
Gets the values of the specified request header.
Header names are case-insensitive. Returns a list of string values matching the header name (or an empty list if not present).
Examples
iex> conn = %Passby.Conn{req_headers: [{"soapaction", "sessionOpen"}]}
iex> Passby.Conn.get_req_header(conn, "SoapAction")
["sessionOpen"]
Sets or adds a response header.
Examples
iex> conn = %Passby.Conn{}
iex> conn = Passby.Conn.put_resp_header(conn, "content-type", "application/json")
iex> conn.resp_headers
[{"content-type", "application/json"}]
Sets the response status and body without immediately transmitting it.
Examples
iex> conn = %Passby.Conn{}
iex> conn = Passby.Conn.resp(conn, 200, "Hello World")
iex> conn.status
200
iex> conn.resp_body
"Hello World"
Sends the response configured in the connection struct over the socket.
Sends the response with the given status and body over the underlying socket.
If no status and body are passed, it sends the response configured in the struct.