mini-server

Crates.iomini-server
lib.rsmini-server
version0.2.4
created_at2023-11-25 22:43:31.171377+00
updated_at2025-10-09 11:59:37.194556+00
descriptionThe mini web server
homepagehttps://github.com/luxluth/mini-server#readme
repositoryhttps://github.com/luxluth/mini-server
max_upload_size
id1048620
size42,467
Delphin Blehoussi (luxluth)

documentation

README

mini-server

The mini rust server

cargo add mini-server

HTTP server

use mini_server::*;

fn main() {
    let mut app = HTTPServer::default();

    app.get("/", |_, _| {
        "Hello World!".into()
    });

    app.run();
}

Dynamic paths

The path is an expression that can contains dynamic variables.

  • Basic paths: /, /this/is/a/path, ...
  • Dynamic path: /this/is/a/@varibale, /this/is/another/#variable

# and @ are prefixes for dynamic values.

  • @ for strings
  • # for denoting integers (i32)
  • #F for floats (f32)
use mini_server::*;

fn main() {
  let mut app = HTTPServer::default();

  app.get("/hello/@name/#age", |_, exprs| {
    let name = expand!(exprs, "name", PathExpr::String);
    let age = expand!(exprs, "age", PathExpr::Number);

    format!("Hello {name}, you are {age}!").into()

  });
}

Examples

To run an example:

cargo run --example $name
Commit count: 43

cargo fmt