Documentation
¶
Overview ¶
internal/utils/tx.go
Index ¶
- Variables
- func GenerateSlug(input string) string
- func GetTxFromContext(ctx context.Context) (*gorm.DB, error)
- func RandomStr() (string, error)
- func SaveRequestContext(cxt context.Context, r RequestResponse) context.Context
- type Hash
- type JwtClaims
- type JwtService
- type NoTransactionError
- type PageIndex
- type RequestResponse
- type Role
- type Token
- type TokenResponse
- type TransactionError
- type TxManager
- type UID
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoTransaction = &NoTransactionError{}
ErrNoTransaction thông báo khi context không chứa transaction
View Source
var KeyReq keyRequest
Functions ¶
func GenerateSlug ¶ added in v1.0.2
func GetTxFromContext ¶ added in v1.0.1
GetTxFromContext lấy transaction từ context (dùng trong repository)
func SaveRequestContext ¶
func SaveRequestContext(cxt context.Context, r RequestResponse) context.Context
Types ¶
type JwtClaims ¶
type JwtClaims struct {
Role string `json:"role"`
jwt.RegisteredClaims
}
type JwtService ¶
type JwtService struct {
// contains filtered or unexported fields
}
func NewJwtServer ¶
func NewJwtServer(secretKey string, expireAt int) *JwtService
func (*JwtService) IssueToken ¶
func (j *JwtService) IssueToken(ctx context.Context, sub string, tid string, role Role) (*TokenResponse, error)
func (JwtService) ParseToken ¶
type NoTransactionError ¶ added in v1.0.1
type NoTransactionError struct{}
func (*NoTransactionError) Error ¶ added in v1.0.1
func (e *NoTransactionError) Error() string
type RequestResponse ¶
func GetRequestContext ¶
func GetRequestContext(cxt context.Context) RequestResponse
func NewRequestResponse ¶
func NewRequestResponse(sub string, tid string) *RequestResponse
type TokenResponse ¶
type TransactionError ¶ added in v1.0.1
TransactionError wrap lỗi rollback và lỗi chính
func (*TransactionError) Error ¶ added in v1.0.1
func (e *TransactionError) Error() string
Click to show internal directories.
Click to hide internal directories.