Skip to content

believemanasseh/rusticore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rusticore

A minimal, customisable and multithreaded web server written in Rust.

Features

  • Simple API for starting and managing the server
  • Easily extensible for custom logic and routing
  • Multithreaded for handling multiple requests concurrently

Installation

From Source

Clone the repository and build with Cargo:

git clone https://github.com/believemanasseh/rusticore.git
cd rusticore
cargo build --release

The compiled binary will be in target/release/rusticore.

From crates.io

Add to your Cargo.toml:

[dependencies]
rusticore = "0.1.0"

Then run:

cargo build --release

Usage

As a Binary

After building, run the server:

./target/release/rusticore

As a Library

Import and use in your Rust project:

use rusticore::Server;
use rusticore::Route;
use http::StatusCode;

#[tokio::main]
async fn main() {
    let mut server = Server::new("localhost", 9000, false, None);
    let route = Route::new(
        "GET",
        "/hello",
        Arc::new(|req, res| Box::pin(async move {
            res.text("Hello, world!", StatusCode::OK).await;
        }))
    );
    server.add_route(route).await;
    server.start().await.unwrap();
}

Testing

To run tests, use:

# Unit tests
cargo test --lib

# Integration tests
cargo test --test test_*

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A minimal multithreaded custom web server in Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages