An open API service indexing awesome lists of open source software.

https://github.com/cachebag/rust-line

HTTP server built in Rust from scratch, for educational purposes.
https://github.com/cachebag/rust-line

Last synced: 2 months ago
JSON representation

HTTP server built in Rust from scratch, for educational purposes.

Awesome Lists containing this project

README

          

# rust-line

A minimal HTTP server built from scratch in Rust

## Endpoints
- `GET /ping` – returns `PONG`.
- `GET /uptime` – returns server uptime.
- `GET /echo/` – echoes `` back.
- `GET /user-agent` – returns the `User-Agent` header from the request.
- `GET /files` - Returns content of a specified file

## Performance (WIP)
`perf.sh` will use `wrk` to run a performance test on the server. It runs 250 connections on 10 threads. It serves `index.html`.
```bash
chmod +x perf.sh
./perf.sh
```
#### Current Benchmarks (may vary based on your machine's specs):
- ~100,000+ requests/second
- ~2.4ms average response time
- Tests 250 concurrent connections on 10 threads
- Throughout -> 6.8MB/s


image

###### **Device Specs**:
image

## Run

No directory specified
```bash
cargo run --release -- ns
````

Set cwd
```bash
cargo run --release -- directory /path/to/dir
````

Default cwd to `.`
```bash
cargo run --release -- directory
````

## Test (WIP)

**Integration Tests**
```bash
cargo test --test load_test -- --nocapture
```
**Unit Tests**
```bash
cargo test --lib
```

**Everything**
```bash
cargo test
```