#web-server #routes #go #standard #pattern #requests #request

rustigo

A Rust webserver inspired by the Go standard library's HTTPServer

3 stable releases

1.1.3 Mar 28, 2024
1.1.1 Dec 10, 2023

#483 in HTTP server

31 downloads per month

MIT license

14KB
310 lines

Rustigo

A Rust webserver inspired by the Go standard library's HTTPServer

Features:

  • Lightweight
  • Pattern matched routes
  • No dependencies

Example

use rustigo::prelude::*;

fn index(stream: TcpStream, _: Request) {
    html!(stream; "<h1>Hello, world!</h1>");
}

fn main() {
    let mut rustigo = Rustigo::default();

    rustigo.handle("/", Arc::new(index));

    rustigo.listen("localhost:7878", 4).unwrap();
}

lib.rs:

Rustigo is a simple web server that allows you to handle requests with ease.

Example usage:

use rustigo::prelude::*;

fn index(stream: TcpStream, _: Request) {
    html!(stream; "<h1>Hello, world!</h1>");
}

fn main() {
    let mut rustigo = Rustigo::default();

    rustigo.handle("/", Arc::new(index));

    rustigo.listen("localhost:7878", 4).unwrap();
}

No runtime deps