Documentation
¶
Overview ¶
Package context contains additional functionality related to the gin-gonic context.
Index ¶
- Variables
- func GetJWT(c *gin.Context) *jwt.Token
- func GetLogger(c *gin.Context) zerolog.Logger
- func GetRequestID(c *gin.Context) string
- func GetSessionID(c *gin.Context) string
- func GetTranslator(c *gin.Context) ut.Translator
- func MarshalSessionData(c *gin.Context, data interface{}) error
- func UnmarshalSessionData(c *gin.Context, obj interface{}) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ( // KeyRequestID is the name of the context key holding the unique request ID. KeyRequestID = "request_id" // KeyLogger is the name of the context key holding the request-specific logger. KeyLogger = "logger" // KeyJWT is the name of the context key holding the JWT token. KeyJWT = "jwt" // KeySessionData is the name of the key where session data is stored. KeySessionData = "session_data" // KeySessionID is the name of the key where the session ID is stored. KeySessionID = "session_id" // KeyTranslator is the name of the key where the i18n translator object is stored. KeyTranslator = "translator" )
Functions ¶
func GetRequestID ¶
GetRequestID returns the request ID from the context.
func GetSessionID ¶
GetSessionID returns the session ID stored in the context.
func GetTranslator ¶
func GetTranslator(c *gin.Context) ut.Translator
GetTranslator returns the translator stored in the context.
func MarshalSessionData ¶
MarshalSessionData saves the given data to the context.
func UnmarshalSessionData ¶
UnmarshalSessionData retrieves session data from the context.
If session data was found and successfully unmarshaled into the given object, a true result is returned with a nil error. If no session data was found, a false result with a nil error is returned. If an error occurs while unmarshaling the data, a false result with an error is returned.
Types ¶
This section is empty.