A lightweight, fast, and modular web framework for Ruby based on Rack. Lennarb supports Ruby (MRI) 3.4+
- Lightweight and modular architecture
- High-performance routing system
- Simple and intuitive API
- Support for middleware
- Flexible configuration options
- Two implementation options:
Lennarb::App
: Minimalist approach for complete controlLennarb::Application
: Extended version with common components
Lennarb offers two implementation approaches to suit different needs:
- Lennarb::App: Minimalist approach for complete control
- Lennarb::Application: Extended version with common components
See the documentation for details on each implementation.
Add this line to your application's Gemfile:
gem 'lennarb'
Or install it directly:
gem install lennarb
require "lennarb"
app = Lennarb::App.new do
config do
mandatory :database_url, string
optional :env, string, "production"
optional :port, int, 9292
end
routes do
get("/") do |req, res|
res.html("<h1>Welcome to Lennarb!</h1>")
end
get("/hello/:name") do |req, res|
name = req.params[:name]
res.html("Hello, #{name}!")
end
end
end
app.initialize!
run app # In config.ru
Start with: rackup
Lennarb is designed for high performance:
Position | Application | 10 RPS | 100 RPS | 1.000 RPS | 10.000 RPS |
---|---|---|---|---|---|
1 | Lenna | 126.252,36 | 108.086,55 | 87.111,91 | 68.460,64 |
2 | Roda | 123.360,37 | 88.380,56 | 66.990,77 | 48.108,29 |
3 | Syro | 114.105,38 | 80.909,39 | 61.415,86 | 46.639,81 |
4 | Hanami-API | 68.089,18 | 52.851,88 | 40.801,78 | 27.996,00 |
See all benchmark graphs
- Getting Started - Setup and first steps
- Performance - Benchmarks and optimization
- Response - Response handling
- Request - Request handling
# Different response types
res.html("<h1>Hello World</h1>")
res.json("{\"message\": \"Hello World\"}")
res.text("Plain text response")
# Route parameters
get("/users/:id") do |req, res|
user_id = req.params[:id]
res.json("{\"id\": #{user_id}}")
end
# Redirects
res.redirect("/new-location")
For more examples and full documentation, see: Complete Lennarb Documentation
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -am 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project uses the Developer Certificate of Origin and is governed by the Contributor Covenant.
MIT License - see the LICENSE file for details.