Refactor session package for better structure and naming conventions

This commit is contained in:
2024-04-26 20:33:34 +07:00
parent 769bffe6ff
commit c43fd0232e
11 changed files with 52 additions and 161 deletions

View File

@ -30,9 +30,9 @@ func POST(w http.ResponseWriter, r *http.Request) {
return
}
storeSession, err := session.Store.Get(cookie.Value)
storeSession, err := session.GlobalSessionStore.Get(cookie.Value)
if err != nil {
if errors.Is(err, &session.SessionNotFound{}) {
if errors.Is(err, &session.SessionNotFoundError{}) {
storeSession.Destroy(w)
}
http.Error(w, err.Error(), http.StatusInternalServerError)

View File

@ -44,9 +44,9 @@ func POST(w http.ResponseWriter, r *http.Request) {
return
}
storeSession, err := session.Store.Get(cookie.Value)
storeSession, err := session.GlobalSessionStore.Get(cookie.Value)
if err != nil {
if errors.Is(err, &session.SessionNotFound{}) {
if errors.Is(err, &session.SessionNotFoundError{}) {
storeSession.Destroy(w)
}
http.Error(w, err.Error(), http.StatusInternalServerError)