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 }