Skip to content

xBeastMode/LightHop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 LightHop

LightHop is a lightweight HTTP static file server written in modern C++.

It listens on a TCP port, accepts incoming HTTP requests, and serves files from a configurable directory — with a focus on simplicity, performance, and clarity.


✨ Features

  • ⚡ Built with modern C++ (C++23) and CMake
  • 🔄 Poll-based event loop for handling multiple clients
  • 📁 Static file serving from a configurable www directory
  • 🌐 Automatic MIME type detection for common file types
  • ⚙️ YAML-based configuration (config.yml) with safe defaults
  • 🪵 Colored runtime logging with timestamps

📦 Requirements

  • CMake 3.20+
  • C++ compiler with C++23 support
  • yaml-cpp (resolved via find_package)
  • POSIX-compatible system (poll, netinet, unistd, etc.)

🛠️ Build

From the project root:

cmake -S . -B build
cmake --build build

The executable will be located in:

./build/LightHop

▶️ Run

Before starting, optionally adjust config.yml.

./build/LightHop

By default:

  • 🌐 Port: 8080
  • 📁 Directory: www/

⚙️ Configuration

LightHop reads settings from config.yml at startup.
If the file is missing or invalid, default values are used.

Key Description Default
port Server port (0–65535) 8080
www-dir Directory for static files www/
poll-timeout Poll timeout in ms (-1 = block) -1
socket-backlog Pending connection queue size 10
buffer-size Per-client read buffer size (bytes) 4096

Notes

  • If www-dir does not exist, it will be created automatically
  • Requesting / serves index.html

📁 Project Structure

LightHop/
├── include/
│   ├── client.h
│   ├── config.h
│   ├── file_reader.h
│   ├── http_response.h
│   ├── logger.h
│   └── server.h
├── src/
│   ├── client.cpp
│   ├── config.cpp
│   ├── file_reader.cpp
│   ├── http_response.cpp
│   ├── main.cpp
│   └── server.cpp
├── config.yml
└── CMakeLists.txt

🧩 Current Scope

  • Serves static files over HTTP
  • Returns 404 Not Found for missing resources
  • Focused on a minimal, clear HTTP response pipeline

🛣️ Roadmap

  • Improve HTTP request parsing and validation
  • Add unit and integration tests
  • Implement graceful shutdown and signal handling
  • Add optional routing and middleware-like extensions

🤝 Contributing

Contributions are welcome:

  1. Fork the repository
  2. Create a feature branch
  3. Commit changes with clear messages
  4. Open a pull request with a short description

📄 License

MIT License

Copyright (c) 2026 Angel Maya

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A lightweight HTTP static file server written in modern C++.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors