Crate http_srv

Source
Expand description

Http Server Crate

This crate contains all the libraries necessary to run an HTTP Server

§Example

use http_srv::prelude::*;

let config = ServerConfig::default();

let mut handler = Handler::new();
handler.add_default(HttpMethod::GET, handler::cat_handler);
handler.get("/", handler::root_handler);
handler.get("/hello", |req: &mut HttpRequest| {
    let name = req.param("name").unwrap_or("friend");
    let msg = format!("Hello {name}!");
    req.respond_str(&msg)
});

let mut server = HttpServer::new(config).unwrap();
server.set_handler(handler);
server.run();

Re-exports§

pub use config::ServerConfig;
pub use http;

Modules§

config
handler
request
response

Structs§

HttpRequest
HTTP Request
HttpResponse
HttpServer
HTTP Server

Type Aliases§

Result
Result type for the http_srv crate