2021-12-12 14:04:11 -08:00
|
|
|
package context
|
|
|
|
|
2022-01-08 21:23:26 -08:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
2021-12-12 14:04:11 -08:00
|
|
|
const (
|
2021-12-18 13:55:35 -08:00
|
|
|
// AuthenticatedUserKey is the key value used to store the authenticated user in context
|
2021-12-12 14:04:11 -08:00
|
|
|
AuthenticatedUserKey = "auth_user"
|
2021-12-18 13:55:35 -08:00
|
|
|
|
|
|
|
// UserKey is the key value used to store a user in context
|
|
|
|
UserKey = "user"
|
|
|
|
|
|
|
|
// FormKey is the key value used to store a form in context
|
|
|
|
FormKey = "form"
|
|
|
|
|
|
|
|
// PasswordTokenKey is the key value used to store a password token in context
|
|
|
|
PasswordTokenKey = "password_token"
|
2024-06-14 18:01:48 -07:00
|
|
|
|
|
|
|
// LoggerKey is the key value used to store a structured logger in context
|
|
|
|
LoggerKey = "logger"
|
2024-06-15 13:56:47 -07:00
|
|
|
|
|
|
|
// SessionKey is the key value used to store the session data in context
|
|
|
|
SessionKey = "session"
|
2021-12-12 14:04:11 -08:00
|
|
|
)
|
2022-01-08 21:23:26 -08:00
|
|
|
|
|
|
|
// IsCanceledError determines if an error is due to a context cancelation
|
|
|
|
func IsCanceledError(err error) bool {
|
|
|
|
return errors.Is(err, context.Canceled)
|
|
|
|
}
|