HttpServer
HttpServer module: server-side HTTP types and pipeline runner.
Built on top of Http (for Method, Header types) and WebSocket modules. Provides the Conn type, pipeline composition, and server startup.
Usage: HttpServer.new(4000) |> HttpServer.max_connections(500) |> HttpServer.idle_timeout(30) |> HttpServer.plug(logger) |> HttpServer.plug(router) |> HttpServer.listen()
Types
Functions
Return the request method atom (:get, :post, …) of a Conn.
Convert a request-method atom to its uppercase string name, suitable for logging, response bodies, or rebuilding a request line. Returns "UNKNOWN" for any atom that is not one of the recognized HTTP verbs. Atoms use lowercase by convention: :get, :post, :put, :patch, :delete, :head, :options, :trace, :connect.
Examples
march> HttpServer.method_to_string(:get)
"GET"
march> HttpServer.method_to_string(:patch)
"PATCH"
march> HttpServer.method_to_string(:not_a_verb)
"UNKNOWN"Return the numeric IP address of the connected peer (the socket's remote address), e.g. "203.0.113.7" or "2001:db8::1".
This is the transport-level address — it cannot be spoofed by request
headers, unlike `X-Forwarded-For`. Behind a reverse proxy it is the
proxy's address, not the end client's.
Returns "" when no live socket backs the conn (e.g. test conns).