Перенести решение лабораторной 1 как основу для лабораторной 2

This commit is contained in:
2026-10-06 11:54:05 +03:00
parent 65003b6119
commit 5c3f2bfad0
54 changed files with 4472 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package httpx
import (
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
const keyUserID = "messenger.user_id"
// SetUserID records the identified caller for the handlers behind the
// identification middleware and for the access log. It lives here rather
// than in the auth package because the access log needs it and auth already
// depends on this package.
func SetUserID(c *gin.Context, id uuid.UUID) {
c.Set(keyUserID, id)
}
func UserID(c *gin.Context) (uuid.UUID, bool) {
v, ok := c.Get(keyUserID)
if !ok {
return uuid.Nil, false
}
id, ok := v.(uuid.UUID)
return id, ok
}