4 releases

Uses new Rust 2024

0.2.1 Apr 9, 2025
0.2.0 Aug 19, 2024
0.1.2 Aug 19, 2024
0.1.0 May 13, 2024
0.0.1 Nov 25, 2023

#392 in HTTP server

Download history 82/week @ 2025-02-12 1/week @ 2025-03-12 132/week @ 2025-04-09

132 downloads per month

MIT license

42KB
910 lines

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 denoting numbers and @ for strings

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

Dependencies

~125KB