22 releases (7 breaking)

Uses new Rust 2024

0.8.0 Jul 1, 2025
0.6.0 May 18, 2025
0.4.0 Feb 19, 2025
0.3.0 Dec 5, 2024
0.1.9 Jul 11, 2024

#568 in HTTP server

Download history

1,301 downloads per month

GPL-3.0-only

105KB
2.5K SLoC

Http Server

Simple HTTP server

== Documentation == To build the documentation, run cargo doc Or browse it online at https://docs.rs/http-srv


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

Dependencies

~230–630KB
~15K SLoC