Refactor and remove sqlite and replace with MySQL
This commit is contained in:
23
internal/handlers/session/account.go
Normal file
23
internal/handlers/session/account.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
)
|
||||
|
||||
var (
|
||||
SessionStore *sessions.CookieStore
|
||||
Name string
|
||||
)
|
||||
|
||||
func GetSession(w http.ResponseWriter, r *http.Request) (*sessions.Session, error) {
|
||||
if SessionStore == nil {
|
||||
return nil, fmt.Errorf("session store not initialized")
|
||||
}
|
||||
if Name == "" {
|
||||
return nil, fmt.Errorf("session name not configured")
|
||||
}
|
||||
return SessionStore.Get(r, Name)
|
||||
}
|
||||
Reference in New Issue
Block a user