AZU Framework
Overview
Installation
dependencies:
azu:
github: azutoolkit/azu
session:
github: azutoolkit/sessionQuick Start
1. Define Your Session Data
# src/sessions/user_session.cr
struct UserSession
include Session::SessionData
property user_id : Int64?
property username : String?
property email : String?
property roles : Array(String) = [] of String
property logged_in_at : Time?
def authenticated? : Bool
!user_id.nil?
end
def admin? : Bool
roles.includes?("admin")
end
end2. Configure Session
3. Create the Session Handler
4. Register the Handler
5. Use Sessions in Endpoints
Helper Module
Logout Endpoint
Flash Messages in Templates
Production Configuration
With Redis and Clustering
With Cookie Store (Stateless)
Testing
Test Helper
Endpoint Tests
Graceful Shutdown
Complete Example
Last updated
Was this helpful?