Struct micro_http_async::HttpServer
source ·
[−]pub struct HttpServer {
pub routes: Routes,
// some fields omitted
}
Expand description
HTTP Server
This struct stores the listener, which listens for incoming connections and handles them
Example:
let http_server = HttpServer::new("127.0.0.1", "8080").await.unwrap(); // Create a new http listener
Fields
routes: Routes
Implementations
New
Create a new server, with a given IP and port
Example
let http_server = HttpServer::new("127.0.0.1", "8080").await.unwrap();
New TLS
Create a new server, with a given IP and port, and a TLS certificate and key
Example
let http_server = HttpServer::new_tls("127.0.0.1", "8080", "cert.pem", "key.pem").await.unwrap();
Note
The certificate and key files must be in PEM and KEY formats respectively. The key must not be encrypted.
Set Read Buffer Size
Set the read buffer size for the server. The default value is 8192 bytes.