Project: sunweb
Sunnickel | 04.10.2025
A lightweight, fast, and flexible HTTP/HTTPS web server written in Rust with domain routing, middleware support, and TLS capabilities.
Features
- Macro-driven routing — define routes with
#[get],#[post],#[put],#[delete],#[patch],#[head],#[options] - HTTP & HTTPS — built-in TLS via
rustls, automatic HTTP → HTTPS redirect - Middleware — request, response, and request+response middleware, scoped by path prefix
- Static file serving —
#[static_files("/assets", "./public")] - Reverse proxy —
#[proxy("/api", "http://localhost:3000")] - Custom error pages —
#[error_page(404)] - Templating (optional feature) — lightweight
{{ var }},{% if %},{% for %}engine - Colored logging — built-in
Loggerwith per-level ANSI colors - Cookie support — full cookie jar on request and response
- Keep-alive — persistent connections handled automatically
Installation
[]
= "0.3.0"
With templating:
[]
= { = "0.3.0", = ["templating"] }
Quick Start
use ;
use LevelFilter;
;
async
HTTPS
builder
.http // redirects to HTTPS automatically
.https
.cert
.domain
.run;
Routing
use ;
async
async
async
Static Files
use static_files;
;
Reverse Proxy
use proxy;
;
Middleware
use ;
// Applies to all routes
// Scoped to /admin/*
// Response middleware
Error Pages
use ;
Templating (feature = "templating")
use ;
async
Template syntax:
| Syntax | Description |
|---|---|
{{ name }} |
Variable interpolation |
{% if condition %} … {% endif %} |
Conditional block |
{% for item in list %} … {% endfor %} |
Loop |
Logging
use Logger;
use LevelFilter;
init;
info!;
warn!;
error!;
| Level | Color |
|---|---|
error |
Red |
warn |
Yellow |
info |
Blue |
debug |
Green |
trace |
Dimmed |
Response Types
| Type | Content-Type |
|---|---|
HtmlResponse |
text/html |
JsonResponse |
application/json |
PlainTextResponse |
text/plain |
ImageResponse |
image/* |
RedirectResponse |
— sets Location header |
NoContentResponse |
204 No Content |
Response |
fully manual |
Workspace Structure
sunweb/
├── sunweb/ # Main crate — public API & re-exports
├── sunweb_core/ # HTTP types, server runtime, request/response
├── sunweb_macros/ # Procedural macros (#[get], #[middleware], etc.)
├── sunweb_templating/ # Optional templating engine
└── example_app/ # Usage examples (not published)
License
MIT — see LICENSE for details.
Contributing
Pull requests are welcome.
Author
Links
AI Assistance
This project's documentation, including this README.md file, has been created with the assistance of AI.
Specifically, AI was used for:
- Documentation generation
- Content creation for this
README.md
All content has been reviewed and edited to ensure accuracy and clarity. While AI tools were utilized to accelerate the writing process, all information has been manually checked for correctness.