16 releases

0.3.2 Jan 19, 2025
0.3.1 Jan 19, 2025
0.3.0 Dec 5, 2024
0.2.2 Aug 26, 2024
0.1.6 May 29, 2024

#317 in HTTP server

Download history 14/week @ 2024-10-02 1/week @ 2024-10-09 114/week @ 2024-12-04 20/week @ 2024-12-11 206/week @ 2025-01-15

206 downloads per month

MIT license

30KB
764 lines

Http Server

Simple HTTP Server in rust.


lib.rs:

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);
server.set_handler(handler);
server.run();

Dependencies

~0.4–0.8MB
~20K SLoC