Azu is a high-performance web framework for Crystal emphasizing type safety, modularity, and real-time capabilities.
require "azu"
module MyApp
include Azu
configure do
port = 3000
end
end
struct HelloRequest
include Azu::Request
getter name : String = "World"
end
struct HelloResponse
include Azu::Response
def initialize(@name : String); end
def render
"Hello, #{@name}!"
end
end
struct HelloEndpoint
include Azu::Endpoint(HelloRequest, HelloResponse)
get "/"
def call : HelloResponse
HelloResponse.new(hello_request.name)
end
end
MyApp.start [
Azu::Handler::Logger.new,
Azu::Handler::Rescuer.new
]HTTP Request → Router → Middleware Chain → Endpoint → Response
↓
Request Contract (validation)
Endpoints are type-safe handlers with:
- Request Contract: Validates and types incoming data
- Response Object: Handles content rendering
- Middleware: Cross-cutting concerns (auth, logging, etc.)
| Feature | Description |
|---|---|
| Type-Safe Contracts | Compile-time validation via Azu::Request |
| Radix Routing | O(log n) lookup with path caching |
| WebSocket Channels | Real-time bidirectional communication |
| Live Components | Server-rendered with client sync (Spark) |
| Multi-Store Cache | Memory and Redis with auto-metrics |
| Middleware Stack | CORS, CSRF, Rate Limiting, Logging |
| New to Azu? | Need to do something? | Looking for API? | Want to understand? |
|---|---|---|---|
| Tutorials | How-To Guides | Reference | Explanation |
Step-by-step lessons to learn Azu:
- Getting Started - Install and create your first app
- Building a User API - Complete CRUD API tutorial
- Adding WebSockets - Real-time features
- Working with Databases - CQL integration
- Testing Your App - Write comprehensive tests
- Deploying to Production - Production deployment
Task-oriented guides for specific goals:
- Endpoints - Create endpoints, handle parameters, return formats
- Validation - Validate requests and models
- Real-Time - WebSocket channels and live components
- Database - Schema, models, queries, transactions
- Caching - Memory and Redis caching
- Middleware - Custom handlers and logging
- Deployment - Production, Docker, scaling
- Performance - Optimize endpoints and queries
Technical specifications and API documentation:
- Core API - Endpoint, Request, Response, Channel, Component
- Handlers - Built-in middleware handlers
- Configuration - All configuration options
- Database - CQL API, validations, query methods
- Error Types - HTTP error classes
Conceptual understanding of Azu:
- Architecture - How Azu works
- Request Lifecycle - Request flow
- Type Safety - Compile-time guarantees
- Design Decisions - Why Azu is built this way
- FAQ - Common questions and troubleshooting
- Contributing - Development setup and guidelines