WIP: Develop #1

Draft
ostiwe wants to merge 10 commits from dev into main
2 changed files with 18 additions and 16 deletions
Showing only changes of commit 465eb99bae - Show all commits

View File

@@ -75,8 +75,7 @@ func (c *Connection) listenCloseNotify() {
)) ))
for { for {
select { <-c.closeNotify
case <-c.closeNotify:
c.logger.Info("Trying to reconnect to rabbit") c.logger.Info("Trying to reconnect to rabbit")
dial, dialErr := amqp.Dial(c.connString) dial, dialErr := amqp.Dial(c.connString)
@@ -91,9 +90,6 @@ func (c *Connection) listenCloseNotify() {
c.logger.Info("Rabbit connection stabilized") c.logger.Info("Rabbit connection stabilized")
break
}
time.Sleep(c.reconnectInterval) time.Sleep(c.reconnectInterval)
} }
} }

View File

@@ -9,6 +9,12 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
type ContextKey string
const (
UserContextKey ContextKey = "user"
)
func SetUserFromJWT() gin.HandlerFunc { func SetUserFromJWT() gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
ctx := c.Request.Context() ctx := c.Request.Context()
@@ -34,7 +40,7 @@ func SetUserFromJWT() gin.HandlerFunc {
return return
} }
ctx = context.WithValue(ctx, "user", user) ctx = context.WithValue(ctx, UserContextKey, user)
c.Request = c.Request.WithContext(ctx) c.Request = c.Request.WithContext(ctx)