Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A simple HTTP session manager

NotificationsYou must be signed in to change notification settings

NHAS/session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A simple HTTP session manager. Got bored and needed to have a session manager that manages idle timeouts as well as longer max timeouts.

Example:

typeSessionEntrystruct {ArbitraryContentstring}sessionManager=NewStore[SessionEntry]("session",time.Duration(IdleTimeDuration)*time.Second)authorisedRoutes:=http.NewServeMux()authorisedRoutes.HandleFunc("/status",status)authorisedRoutes.HandleFunc("/dashboard/",dashboard)log.Fatal(http.ListenAndServe(addr,sessionManager.AuthorisationChecks(authorisedRoutes,nil)))
_,data:=sessionManager.GetSessionFromRequest(r)ifdata==nil {http.Error(w,"No",http.StatusUnauthorized)return}
sessionKey:=sessionManager.StartSession(w,r,currentSession,func(sessionSessionEntry) {// Do something on session expiry})// Do stuffsessionManager.DeleteSession(w,r)

About

A simple HTTP session manager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp