Documentation ¶
Index ¶
- Constants
- func AddExtraInfoToContext(c *gin.Context, key string, value interface{})
- func Atoi(s string, default_value int) int
- func ErrorHandler() gin.HandlerFunc
- func GenerateAad() []byte
- func GenerateID() string
- func GenerateIv() []byte
- func GenerateMsgID(address string, length ...int) string
- func GenerateSalt() []byte
- func GenerateToken(val string) string
- func GenerateUUID() string
- func GetUser(verifyKey crypto.PublicKey) gin.HandlerFunc
- func HmacSha1(plainText string) string
- func HmacSha1WithKey(plainText []byte, key string) string
- func HmacSha1WithKeyByte(plainText []byte, key string) []byte
- func HmacSha256(pubKey, plaintex []byte) string
- func HmacSha512(plaintex string) string
- func HmacSha512Rand(category string) string
- func InitLogger(logConfig *config.LogConfig)
- func Int64ToString(d int64) string
- func LoadEdPrivateKeyFromDisk(location string) crypto.PrivateKey
- func LoadEdPublicKeyFromDisk(location string) crypto.PublicKey
- func OptionsHeader() gin.HandlerFunc
- func OutHttpJson(c *gin.Context, code int, message string, data interface{}, statusCode ...int)
- func RandBytes(len int) ([]byte, error)
- func RandInt64(min, max int64) int64
- func RandStr(strlen int) string
- func ResponseErrorJson(c *gin.Context, err error)
- func ResponseFailedJson(c *gin.Context, code int, message string, data interface{}, statusCode ...int)
- func ResponseSuccessJson(c *gin.Context, data interface{}, statusCode ...int)
- func ResponseSuccessJsonWithPagination(c *gin.Context, data interface{}, p *Pagination, statusCode ...int)
- func ResponseText(c *gin.Context, text string, statusCode ...int)
- func Sha1Digest(plaintext string) (result string)
- func Sha1Hex(plaintext string) (result string)
- func Sha256(plaintext []byte) []byte
- func Sha256Digest(plaintext string) (result string)
- func Sha256Hex(plaintext string) (result string)
- func Sha256HexBytes(plaintext string) []byte
- func StringToHex(str string) ([]byte, error)
- func TimestampString() string
- func TrailClient(domain string, maxAge int) gin.HandlerFunc
- func UserAuthen(verifyKey crypto.PublicKey) gin.HandlerFunc
- func VerifyRefleshToken(t string, verifyKey *crypto.PublicKey) (*jwt.Token, error)
- type AccessClaims
- type ClientInfo
- type Pagination
- type RefreshClaims
- type Response
Constants ¶
View Source
const ( ERRCODE_CUSTOM = 40001 ERRCODE_SERVER_ERROR = 40002 ERRCODE_DATABASE_ERROR = 40003 ERRCODE_REQUEST_PARAM_ERROR = 40004 ERRCODE_NOT_LOGINED = 40005 ERRCODE_USER_NOT_EXIST = 40006 ERRCODE_INVALID_SESSION = 40101 ERRCODE_INVALID_Id = 40102 ERRCODE_INVALID_TOKEN = 40103 SUCCESS_CODE_CUSTOM = 2000 )
View Source
const ( ERRMSG_CUSTOM = "custom error" ERRMSG_SERVER_ERROR = "server error" ERRMSG_DATABASE_ERROR = "database error" ERRMSG_PARAM_ERROR = "param error" ERRMSG_REQUEST_PARAM_ERROR = "request param error" ERRMSG_NOT_LOGINED = "not logined" ERRMSG_USER_NOT_EXIST = "user not exist" ERRMSG_INVALID_SESSION = "invalid session" ERRMSG_INVALID_Id = "invalid id" ERRMSG_INVALID_TOKEN = "invalid token" SUCCESS_MSG_CUSTOM = "success" )
View Source
const ( TOKEN_IN_HEADER = "X-Auth-Token" USER_TOKEN_REDIS_PREFIX = "USER:TOKEN:" USER_SID_REDIS_PREFIX = "USER:SID:" TOKEN_EXPIRE = 1 * time.Hour REFRESH_EXPIRE = 24 * TOKEN_EXPIRE )
View Source
const ( EXTRA_INFO = "extra-info" LOGINED = "logined" )
View Source
const ( SESSION_COOKIE_NAME = "SID" CLIENT_KEY = "client" UID_KEY = "UID" )
View Source
const ( TOKEN_TYPE_ACCESS = "access_token" TOKEN_TYPE_REFRESH = "refresh_token" )
View Source
const (
DEFAULT_SIZE = 10
)
Variables ¶
This section is empty.
Functions ¶
func AddExtraInfoToContext ¶
func ErrorHandler ¶
func ErrorHandler() gin.HandlerFunc
func GenerateMsgID ¶
GenerateMsgID Create Message ID
func GenerateUUID ¶
func GenerateUUID() string
func HmacSha1WithKey ¶
HmacSha1WithKey Hmac sha1 with key
func HmacSha1WithKeyByte ¶
HmacSha1WithKey Hmac sha1 with key
func InitLogger ¶
func LoadEdPrivateKeyFromDisk ¶
func LoadEdPrivateKeyFromDisk(location string) crypto.PrivateKey
func LoadEdPublicKeyFromDisk ¶
func OptionsHeader ¶
func OptionsHeader() gin.HandlerFunc
func OutHttpJson ¶
func ResponseErrorJson ¶
func ResponseFailedJson ¶
func ResponseSuccessJson ¶
func ResponseSuccessJsonWithPagination ¶
func ResponseSuccessJsonWithPagination(c *gin.Context, data interface{}, p *Pagination, statusCode ...int)
func Sha256HexBytes ¶
func TrailClient ¶
func TrailClient(domain string, maxAge int) gin.HandlerFunc
func UserAuthen ¶
func UserAuthen(verifyKey crypto.PublicKey) gin.HandlerFunc
Types ¶
type AccessClaims ¶
type ClientInfo ¶
type ClientInfo struct { Ip string Platform string Os string UserAgent string SessionId string UserId int64 RequestId string }
func GetClientInfo ¶
func GetClientInfo(c *gin.Context) (*ClientInfo, error)
func (*ClientInfo) LogFormatLong ¶
func (c *ClientInfo) LogFormatLong() string
func (*ClientInfo) LogFormatShort ¶
func (c *ClientInfo) LogFormatShort() string
func (*ClientInfo) LogFormatShortAndIp ¶
func (c *ClientInfo) LogFormatShortAndIp() string
type Pagination ¶
type Pagination struct { Size int `json:"size"` Page int `json:"page"` Count int `json:"count"` Sort string `json:"sort"` }
func GeneratePaginationFromRequest ¶
func GeneratePaginationFromRequest(c *gin.Context, default_size int) *Pagination
type RefreshClaims ¶
Click to show internal directories.
Click to hide internal directories.