pub struct HttpServer {
pub routes: Routes,
/* private fields */
}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 listenerFields§
§routes: RoutesImplementations§
Source§impl HttpServer
impl HttpServer
Sourcepub async fn new(ip: &str, port: &str) -> Result<Self>
pub async fn new(ip: &str, port: &str) -> Result<Self>
§New
Create a new server, with a given IP and port
Example
let http_server = HttpServer::new("127.0.0.1", "8080").await.unwrap();Sourcepub async fn new_tls(
ip: &str,
port: &str,
cert_path: PathBuf,
key_path: PathBuf,
) -> Result<Self>
pub async fn new_tls( ip: &str, port: &str, cert_path: PathBuf, key_path: PathBuf, ) -> Result<Self>
§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.
Auto Trait Implementations§
impl !Freeze for HttpServer
impl !RefUnwindSafe for HttpServer
impl !Send for HttpServer
impl !Sync for HttpServer
impl Unpin for HttpServer
impl !UnwindSafe for HttpServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more