httpHTTP server for handling web requests.
Provides a blocking HTTP server that listens on a TCP address, accepts incoming requests, and sends responses.
import std::http;
fn main() {
let server = http.listen(":8080");
loop {
let req = server.accept();
let path = req.path();
req.respond_text(200, "Hello from Hew!");
}
}
listenCreate a new HTTP server listening on the given address.
The address format is "host:port" or ":port" to listen on all
interfaces.
let server = http.listen(":8080");
let server = http.listen("127.0.0.1:3000");
ServerAn HTTP server bound to a TCP address.
Created by calling http.listen(addr). Use accept() to wait for
incoming requests in a loop.
RequestAn incoming HTTP request.
Obtained from server.accept(). Provides accessors for the request
method, path, headers, and body. Must be responded to with one of
the respond methods.
ServerMethodsMethods available on an HTTP Server.
RequestMethodsMethods available on an HTTP Request.