| Crates.io | hotaru |
| lib.rs | hotaru |
| version | 0.7.7 |
| created_at | 2025-11-21 15:48:16.36891+00 |
| updated_at | 2026-01-13 16:56:40.747525+00 |
| description | Small, sweet, easy framework for full-stack web application |
| homepage | https://fds.rs/hotaru/ |
| repository | https://github.com/Field-of-Dreams-Studio/hotaru |
| max_upload_size | |
| id | 1943738 |
| size | 75,747 |
Small, sweet, easy framework for full-stack Rust web applications
We rebased our code since July this year. Please refer to the following link if you are interested in our history of building the framework
https://github.com/Redstone-D/starberry
Hotaru is a lightweight, intuitive web framework focused on simplicity and productivity. It supports regex-based routing, tree-structured URLs, and integrates seamlessly with the Akari templating system.
MSRV: 1.86
use hotaru::prelude::*;
pub static APP: SApp = Lazy::new(|| {
App::new()
.binding("127.0.0.1:3000")
.build()
});
#[tokio::main]
async fn main() {
APP.clone().run().await;
}
endpoint! {
APP.url("/"),
pub index<HTTP> {
text_response("Hello, Hotaru!")
}
}
Install the Hotaru CLI tool:
cargo install hotaru
Create a new project:
hotaru new my_app
cd my_app
cargo run
Add to your Cargo.toml:
[dependencies]
hotaru = "0.7.3"
tokio = { version = "1", features = ["full"] }
Hotaru supports the following optional features:
debug: Enable debug logging for development and troubleshooting
external-ctor: Use the external ctor crate instead of Hotaru's built-in constructor implementation
Note: When enabling external-ctor, you must also add ctor to your dependencies:
[dependencies]
hotaru = { version = "0.7.3", features = ["external-ctor"] }
ctor = "0.4.0" # Required when external-ctor feature is enabled
tokio = { version = "1", features = ["full"] }
By default, Hotaru uses a built-in constructor implementation that doesn't require any external dependencies.
Hotaru provides a CLI tool to help you scaffold and manage projects quickly.
⚠️ IMPORTANT: It is crucial to use the CLI tool (hotaru new or hotaru init) when creating a new Hotaru project. The CLI automatically generates essential files including:
build.rs - Required for asset management and resource copyingresource.rs - Helper module for locating templates and static files at runtimeWithout these files, your project will not be able to properly locate and serve templates or static assets. Manual setup is significantly more complex and error-prone.
cargo install hotaru
Note: After installation, make sure Cargo's bin directory is in your PATH. If the hotaru command is not found, add Cargo's bin directory to your PATH:
# Linux/macOS
export PATH="$HOME/.cargo/bin:$PATH"
# Windows (PowerShell)
$env:Path += ";$env:USERPROFILE\.cargo\bin"
To make this permanent, add the export line to your shell configuration file (~/.bashrc, ~/.zshrc, etc.).
hotaru new <project_name>Create a new Hotaru project with a complete project structure:
hotaru new my_app
This generates:
src/main.rs - Main application entry point with a hello world endpointsrc/resource.rs - Resource file locator helper modulebuild.rs - Build script for asset managementCargo.toml - Pre-configured with Hotaru dependenciestemplates/ - Directory for Akari HTML templatesprogramfiles/ - Directory for static assets (CSS, JS, images)The generated project uses the latest Hotaru features including:
LApp! macro for clean app initializationendpoint! macro for routinghotaru initInitialize an existing Cargo project with Hotaru scaffolding:
cd my_existing_project
hotaru init
This command adds the same structure as hotaru new but to your current project directory.
After creating a project:
cd my_app
cargo run
Your server will start at http://127.0.0.1:3000 by default, serving a "Hello, world!" response at the root path.
my_app/
├── Cargo.toml # Dependencies and project metadata
├── build.rs # Asset copying build script
├── src/
│ ├── main.rs # Application entry point
│ └── resource.rs # Resource locator helpers
├── templates/ # Akari HTML templates
└── programfiles/ # Static assets (CSS, JS, images)
The build script automatically copies templates/ and programfiles/ to the target directory during compilation, making them accessible to your application at runtime.
Define routes with the endpoint! macro:
endpoint! {
APP.url("/users/<int:id>"),
pub get_user<HTTP> {
let user_id = req.param("id");
json_response(json!({ "id": user_id }))
}
}
endpoint! and middleware! auto-register at startup (constructor-based), so there is no manual router.register() step.{} and place doc comments inside the macro block.pub fn name(req: HTTP) { ... }; angle-bracket form defaults to req.macro_ra.md for the minimal syntax and rationale.Create reusable middleware:
use htmstd::session::CookieSession;
pub static APP: SApp = Lazy::new(|| {
App::new()
.binding("127.0.0.1:3000")
.append_middleware::<CookieSession>()
.build()
});
Render HTML with Akari:
endpoint! {
APP.url("/profile"),
pub profile<HTTP> {
let data = json!({ "name": "Alice" });
template_response("profile.html", data)
}
}
Configure request validation per endpoint:
endpoint! {
APP.url("/upload"),
config = [HttpSafety::new()
.with_max_body_size(50 * 1024 * 1024) // 50MB
.with_allowed_methods(vec![HttpMethod::POST])
],
pub upload<HTTP> {
// Handle file upload
}
}
Access client IP addresses and connection details directly from your handlers:
endpoint! {
APP.url("/api/whoami"),
pub whoami<HTTP> {
// Get client's full socket address (IP + port)
match req.client_ip() {
Some(addr) => text_response(format!("Your address: {}", addr)),
None => text_response("Unknown client"),
}
}
}
Available Methods:
| Method | Return Type | Description |
|---|---|---|
client_ip() |
Option<SocketAddr> |
Client's socket address (IP + port) |
client_ip_or_default() |
SocketAddr |
Returns 0.0.0.0:0 if unknown |
client_ip_only() |
Option<IpAddr> |
Just the IP address, no port |
client_ip_only_or_default() |
IpAddr |
Returns 0.0.0.0 if unknown |
server_addr() |
Option<SocketAddr> |
Server's bound address |
remote_addr() |
Option<SocketAddr> |
Alias for client_ip() |
local_addr() |
Option<SocketAddr> |
Alias for server_addr() |
Note: When behind a reverse proxy, client_ip() returns the proxy's address. Use headers like X-Forwarded-For or X-Real-IP to get the original client IP.
Check out the example repository for:
Hotaru is built on a modular architecture:
.worker() method now properly configures dedicated worker threads per App instanceLApp!, LUrl!, LPattern! macros for simplified lazy static declarationshotaru new and hotaru init to generate correct endpoint! macro syntaxctor dependency required)ctx.client_ip() and related methods for accessing socket addresses in handlers| Version No. | Content | Release Date (Approx.) |
|---|---|---|
| 0.8.0 | HTTP Outbound | Jan.2026 |
| 0.8.3 | Using new template engine | Jan.2026 |
| 0.8.9 | Bug Fixes | May.2026 |
| Video Resources | URL |
|---|---|
| Quick Tutorial | Youtube: https://www.youtube.com/watch?v=8pV-o04GuKk&t=6s Bilibili: https://www.bilibili.com/video/BV1BamFB7E8n/ |
We believe in transparency about AI-assisted development. Below is an honest breakdown of AI involvement per module:
| Name | Usage of AI | Comments |
|---|---|---|
| hotaru_core/app | Minimal | |
| hotaru_core/connection | Some | |
| hotaru_core/url | Minor | |
| hotaru_core/http | Minor | |
| hotaru_lib | Some | Basic API Access |
| hotaru_meta/endpoint | None | |
| hotaru_meta/middleware | None | |
| ahttpm | Major | Import Akari_macro and Improvements |
| h2per | Major | Integration of Hyper - Not stable yet |
| htmstd/cors | Minimal | |
| htmstd/session | Minimal |
Explanation of terms:
| Term | Meaning |
|---|---|
| None | Full human code, no AI tools used |
| Minimal | AI used for autocompletion, minor suggestions, or documentation only |
| Minor | Some tabs. A few AI generated functions for logic. Testing code maybe written by AI |
| Some | Planning maybe done by AI. Overall structure written by human. Less than a third of real implementation written by AI |
| Major | Planning is done by AI. Overall structure generated by AI with supervision of human. More than a third of real implementation written by AI |
GPL-3.0 License
Copyright (c) 2024-2025 Redstone @ Field of Dreams Studio