mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 21:10:18 +09:00
24 lines
466 B
Go
24 lines
466 B
Go
package utils
|
|
|
|
import (
|
|
"database/sql"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/go-redis/redis/v8"
|
|
)
|
|
|
|
func GetDBFromContext(c *gin.Context) *sql.DB {
|
|
return c.MustGet("db").(*sql.DB)
|
|
}
|
|
|
|
func GetCacheFromContext(c *gin.Context) *redis.Client {
|
|
return c.MustGet("cache").(*redis.Client)
|
|
}
|
|
|
|
func GetUserFromContext(c *gin.Context) string {
|
|
return c.MustGet("user").(string)
|
|
}
|
|
|
|
func GetAgentFromContext(c *gin.Context) string {
|
|
return c.MustGet("agent").(string)
|
|
}
|