You've already forked golang-base-project
Improves documentation (#13)
* Documents all env variables and adds an example project * Adds godoc comments * Fixed package naming issue
This commit is contained in:
@ -8,10 +8,14 @@ import (
|
||||
"log"
|
||||
)
|
||||
|
||||
// SessionIDKey is the key used to set and get the session id in the context of the current request
|
||||
const SessionIDKey = "SessionID"
|
||||
|
||||
// Session middleware checks for an active session and sets the UserIDKey to the context of the current request if found
|
||||
func Session(db *gorm.DB) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
sessionIdentifierInterface := session.Get(SessionIdentifierKey)
|
||||
sessionIdentifierInterface := session.Get(SessionIDKey)
|
||||
|
||||
if sessionIdentifier, ok := sessionIdentifierInterface.(string); ok {
|
||||
ses := models.Session{
|
||||
|
Reference in New Issue
Block a user