require "http-session" module CrystalGauntlet::Templates extend self macro dir_header() path_split = context.request.path.split('/') "
" + path_split.map_with_index { |v, i| "#{i == 0 ? "crystal-gauntlet" : v}"}.join(" / ") + "
" end def footer() %(
Crystal #{Crystal::VERSION}
#{Crystal::BUILD_COMMIT}
running on
#{System.hostname}
for #{CrystalGauntlet.uptime_s}
) end end module CrystalGauntlet record UserSession, username : String, account_id : Int32, user_id : Int32 # todo: replace memory storage with sqlite maybe? has to be hand-written but oh well @@session_storage = HTTPSession::Storage::Memory(UserSession).new @@sessions : HTTPSession::Manager(UserSession) = HTTPSession::Manager.new(@@session_storage, HTTP::Cookie.new("surveillance_device", "", secure: false, http_only: true, max_age: 365.days)) spawn do session_storage.run_gc_loop end def self.session_storage @@session_storage end def self.sessions @@sessions end end