Documentation
¶
Index ¶
- Constants
- Variables
- func AddDuration(t time.Time, duration time.Duration) int64
- func Black(str string, modifier ...interface{}) string
- func Blue(str string, modifier ...interface{}) string
- func Brown(str string, modifier ...interface{}) string
- func Close_Timer(f func()) chan struct{}
- func ConvertMsg(obj interface{}) ([]byte, error)
- func ConvertObj(msg []byte, obj interface{}) error
- func CreateFile(filename string) error
- func Cross() gin.HandlerFunc
- func CurrentUnixNanoTimestamp() int64
- func CurrentUnixTimestamp() int64
- func Cyan(str string, modifier ...interface{}) string
- func DarkGray(str string, modifier ...interface{}) string
- func Debug(formating string, args ...interface{})
- func Deserialization(byt []byte, ptr interface{}) (err error)
- func Error(formating string, args ...interface{})
- func GetCurrentPath() string
- func GetFileToDirectory(path string) string
- func GetNowUnixSec() int64
- func Green(str string, modifier ...interface{}) string
- func HMACSM3(key, data []byte) []byte
- func HMACSM3Equal(mac1, mac2 []byte) bool
- func IfElse(condition bool, trueVal, falseVal interface{}) interface{}
- func Info(formating string, args ...interface{})
- func IsFunctionExists(class interface{}, name string) bool
- func LightBlue(str string, modifier ...interface{}) string
- func LightCyan(str string, modifier ...interface{}) string
- func LightGray(str string, modifier ...interface{}) string
- func LightGreen(str string, modifier ...interface{}) string
- func LightPurple(str string, modifier ...interface{}) string
- func LightRed(str string, modifier ...interface{}) string
- func LoadCertificateFromBuf(buf []byte) (*gmX509.Certificate, error)
- func LoadCertificateFromPEM(filePath string) (*gmX509.Certificate, error)
- func MakeSignature(data []byte, privKey *SM2PrivateKey, userID []byte) ([]byte, error)
- func NewEngine(config *EngineConfig) (*gin.Engine, error)
- func PathExists(path string) (bool, error)
- func ProcessNotify(addr string)
- func Purple(str string, modifier ...interface{}) string
- func ReadAll(path string) (data string, err error)
- func Red(str string, modifier ...interface{}) string
- func RegRouterHandlerController(http *http.Server, method string, relativePath string, v interface{})
- func RequestID() gin.HandlerFunc
- func SM2Decrypt(privKey *SM2PrivateKey, ciphertext []byte) ([]byte, error)
- func SM2DecryptC1C2C3(privKey *SM2PrivateKey, ciphertext []byte) ([]byte, error)
- func SM2DecryptC1C3C2(privKey *SM2PrivateKey, ciphertext []byte) ([]byte, error)
- func SM2Encrypt(pubKey *SM2PublicKey, plaintext []byte) ([]byte, error)
- func SM2EncryptC1C2C3(pubKey *SM2PublicKey, plaintext []byte) ([]byte, error)
- func SM2EncryptC1C3C2(pubKey *SM2PublicKey, plaintext []byte) ([]byte, error)
- func SM2GenerateKey() (*SM2PrivateKey, *SM2PublicKey, error)
- func SM2Sign(privKey *SM2PrivateKey, data []byte, userID ...[]byte) ([]byte, error)
- func SM2Verify(pubKey *SM2PublicKey, data, signature []byte, userID ...[]byte) bool
- func SM3(data []byte) []byte
- func SM4CBCDecrypt(ciphertext []byte, key [MinKeyLen]byte) ([]byte, error)
- func SM4CBCDecryptEx(ciphertext []byte, iv [sm4.BlockSize]byte, key [MinKeyLen]byte) ([]byte, error)
- func SM4CBCEncrypt(buf []byte, key [MinKeyLen]byte) ([]byte, []byte, error)
- func SM4CBCEncryptEx(data []byte, key [MinKeyLen]byte) ([]byte, [sm4.BlockSize]byte, error)
- func SM4Decrypt(key, ciphertext []byte) ([]byte, error)
- func SM4DecryptIV(key, iv, ciphertext []byte) ([]byte, error)
- func SM4Encrypt(key, plaintext []byte) ([]byte, error)
- func SM4EncryptIV(key, iv, plaintext []byte) ([]byte, error)
- func Serialization(value interface{}) ([]byte, error)
- func StringToUnixTimestamp(timeStr string) (int64, error)
- func SubtractDuration(t time.Time, duration time.Duration) int64
- func ToAddr(host string, port int) string
- func ToAddress(host string, port string) string
- func ToUrlAddr(host string, port int) string
- func UnixNanoTimestamp(t time.Time) int64
- func UnixTimestamp(t time.Time) int64
- func UnixTimestampToString(timestamp int64) string
- func VerifySignature(data []byte, sign [64]byte, publicKey *SM2PublicKey, userID []byte) error
- func WalkDir(dirPth, suffix string) (files []string, err error)
- func Warning(formating string, args ...interface{})
- func White(str string, modifier ...interface{}) string
- func WriteFile(filename string, data string) (err error)
- func XZCompress(data []byte) ([]byte, error)
- func XZDecompress(data []byte) ([]byte, error)
- func Yellow(str string, modifier ...interface{}) string
- type Btree
- type Controller
- func (c *Controller) DelSessionKV(context *gin.Context, key interface{})
- func (c *Controller) GetBody(context *gin.Context) ([]byte, error)
- func (c *Controller) GetSessionKV(context *gin.Context, key interface{}) interface{}
- func (c *Controller) SaveBody(context *gin.Context) error
- func (c *Controller) SaveSession(context *gin.Context)
- func (c *Controller) ServiceFinish(context *gin.Context, status int, res interface{})
- func (c *Controller) ServiceFinishAsciiJSON(context *gin.Context, status int, res interface{})
- func (c *Controller) ServiceFinishString(context *gin.Context, status int, data string)
- func (c *Controller) SetHttpServer(web *http.Server)
- func (c *Controller) SetSessionKV(context *gin.Context, key interface{}, val interface{})
- type ControllerInterface
- type ControllerTables
- type Database
- func (db *Database) Close() error
- func (db *Database) CountWhere(obj interface{}, where string, args ...interface{}) (int64, error)
- func (db *Database) CreateTable(obj interface{}) error
- func (db *Database) Delete(obj interface{}) error
- func (db *Database) DropTable(obj interface{}) error
- func (db *Database) Exec(query string, args ...interface{}) (sql.Result, error)
- func (db *Database) Find(obj interface{}) error
- func (db *Database) FindAsc(obj interface{}, orderBy string) error
- func (db *Database) FindDesc(obj interface{}, orderBy string) error
- func (db *Database) FindWhere(obj interface{}, where string, args ...interface{}) error
- func (db *Database) FindWhereAsc(obj interface{}, where string, orderBy string, args ...interface{}) error
- func (db *Database) FindWhereDesc(obj interface{}, where string, orderBy string, args ...interface{}) error
- func (db *Database) Get(obj interface{}) (bool, error)
- func (db *Database) GetWhere(obj interface{}, where string, args ...interface{}) (bool, error)
- func (db *Database) Insert(obj interface{}) error
- func (db *Database) Open(st, addr string, out io.Writer) error
- func (db *Database) Ping() error
- func (db *Database) Select(obj interface{}, it func(idx int, bean interface{}) error) error
- func (db *Database) SyncTable(obj interface{}) error
- func (db *Database) TableExists(obj interface{}) bool
- func (db *Database) Transactions(obj interface{}, it func(it interface{}) error) error
- func (db *Database) Update(obj interface{}, where interface{}) error
- type EngineConfig
- type Handle
- type Job
- func (j *Job) At(hour, min uint) *Job
- func (j *Job) Days() *Job
- func (j *Job) Do(jobFunc interface{}, params ...interface{})
- func (j *Job) Every(interval uint64) *Job
- func (j *Job) GetName() string
- func (j *Job) Hours() *Job
- func (j *Job) Minutes() *Job
- func (j *Job) Rename(name string)
- func (j Job) Run()
- func (j *Job) Seconds() *Job
- type List
- type Logger
- func (l *Logger) Close()
- func (l *Logger) Debug(formating string, args ...interface{})
- func (l *Logger) Error(formating string, args ...interface{})
- func (l *Logger) GetIo() *os.File
- func (l *Logger) Info(formating string, args ...interface{})
- func (l *Logger) SetMode(debug bool)
- func (l *Logger) Warning(formating string, args ...interface{})
- type Map
- type Queue
- type RedisContainer
- func (c *RedisContainer) ClearDB() error
- func (c *RedisContainer) Close()
- func (c *RedisContainer) Delete(keys ...interface{}) (bool, error)
- func (c *RedisContainer) ExistIs(name string) (bool, error)
- func (c *RedisContainer) ExistsHash(name, field string) (bool, error)
- func (c *RedisContainer) GetConn() redis.Conn
- func (c *RedisContainer) GetDBSize() int64
- func (c *RedisContainer) GetH(name, field string, v interface{}) (err error)
- func (c *RedisContainer) GetHM(name string, fields ...string) ([]interface{}, error)
- func (c *RedisContainer) GetString(name string) (string, error)
- func (c *RedisContainer) HashLen(name string) (int, error)
- func (c *RedisContainer) Hashdel(name, key string) (bool, error)
- func (c *RedisContainer) Push(name string, msg []byte) error
- func (c *RedisContainer) ScardInt64s(name string) (int64, error)
- func (c *RedisContainer) SetExpireTime(name string, newSecondsLifeTime int64) error
- func (c *RedisContainer) SetH(name string, key string, value interface{}) (err error)
- func (c *RedisContainer) SetHM(name string, obj interface{}) (err error)
- func (c *RedisContainer) SetString(name string, v interface{}) error
- func (c *RedisContainer) Smembers(name string, v interface{}) (err error)
- func (c *RedisContainer) StrKeyLen(name string) (int, error)
- func (c *RedisContainer) StringIncr(name string) (int, error)
- type RefCounter
- type SM2PrivateKey
- type SM2PublicKey
- type Scheduler
- type Semp
- type ServerConfig
- type Timer
- func (this *Timer) CreateTickController(tmsec time.Duration)
- func (this *Timer) CreateTimeController(tmsec time.Duration)
- func (this *Timer) DelTickController() bool
- func (this *Timer) DelTimeController() bool
- func (this *Timer) UpdateTimeController(tmsec time.Duration) bool
- func (this *Timer) WaitTimerClose()
- type Web
- func (web *Web) AddController(v interface{})
- func (web *Web) GetConfig() *ServerConfig
- func (web *Web) GetGinEngine() *gin.Engine
- func (web *Web) GetHandler() *http.Server
- func (web *Web) HttpClose() error
- func (web *Web) RegisterController()
- func (web *Web) RunService(ip string, port string) error
- func (web *Web) RunServiceTLS(ip string, port string, cert, key string) error
- func (web *Web) Shutdown(timeout time.Duration) error
Constants ¶
View Source
const (
MinKeyLen = 16
)
Variables ¶
View Source
var ( MethodHttpGet = "GET" MethodHttpPost = "POST" MethodHttpDelete = "DELETE" MethodHttpPut = "PUT" )
View Source
var ( ErrSM4InvalidKeyLength = errors.New("SM4 key must be 16 bytes") ErrSM4InvalidBlockSize = errors.New("SM4 ciphertext must be multiple of 16 bytes") )
View Source
var DefaultUserID = []byte("1234567812345678")
DefaultUserID is the default user ID for SM2 signature, matching gmssl default: "1234567812345678"
View Source
var ErrInvalidCiphertext = errors.New("invalid SM2 ciphertext")
View Source
var (
Userid = []byte{0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38}
)
Functions ¶
func Close_Timer ¶
func Close_Timer(f func()) chan struct{}
func ConvertMsg ¶
func ConvertObj ¶
func Cross ¶
func Cross() gin.HandlerFunc
func CurrentUnixNanoTimestamp ¶
func CurrentUnixNanoTimestamp() int64
func CurrentUnixTimestamp ¶
func CurrentUnixTimestamp() int64
func Deserialization ¶
func GetCurrentPath ¶
func GetCurrentPath() string
func GetFileToDirectory ¶
func GetNowUnixSec ¶
func GetNowUnixSec() int64
func HMACSM3Equal ¶
func IsFunctionExists ¶
func LightGreen ¶
func LightPurple ¶
func LoadCertificateFromBuf ¶
func LoadCertificateFromBuf(buf []byte) (*gmX509.Certificate, error)
func LoadCertificateFromPEM ¶
func LoadCertificateFromPEM(filePath string) (*gmX509.Certificate, error)
func MakeSignature ¶
func MakeSignature(data []byte, privKey *SM2PrivateKey, userID []byte) ([]byte, error)
func ProcessNotify ¶
func ProcessNotify(addr string)
func RequestID ¶
func RequestID() gin.HandlerFunc
func SM2Decrypt ¶
func SM2Decrypt(privKey *SM2PrivateKey, ciphertext []byte) ([]byte, error)
func SM2DecryptC1C2C3 ¶
func SM2DecryptC1C2C3(privKey *SM2PrivateKey, ciphertext []byte) ([]byte, error)
func SM2DecryptC1C3C2 ¶
func SM2DecryptC1C3C2(privKey *SM2PrivateKey, ciphertext []byte) ([]byte, error)
func SM2Encrypt ¶
func SM2Encrypt(pubKey *SM2PublicKey, plaintext []byte) ([]byte, error)
func SM2EncryptC1C2C3 ¶
func SM2EncryptC1C2C3(pubKey *SM2PublicKey, plaintext []byte) ([]byte, error)
func SM2EncryptC1C3C2 ¶
func SM2EncryptC1C3C2(pubKey *SM2PublicKey, plaintext []byte) ([]byte, error)
func SM2GenerateKey ¶
func SM2GenerateKey() (*SM2PrivateKey, *SM2PublicKey, error)
func SM2Verify ¶
func SM2Verify(pubKey *SM2PublicKey, data, signature []byte, userID ...[]byte) bool
func SM4CBCDecrypt ¶
SM4CBCDecrypt 对数据进行 SM4 CBC 解密(从加密数据中提取IV) 参数:ciphertext - 加密数据(包含IV),key - 16字节密钥 返回值:解密后的数据、错误
func SM4CBCDecryptEx ¶
func SM4CBCDecryptEx(ciphertext []byte, iv [sm4.BlockSize]byte, key [MinKeyLen]byte) ([]byte, error)
SM4CBCDecryptEx 对数据进行 SM4 CBC 解密(外部传入IV) 参数:ciphertext - 加密数据,iv - 初始向量,key - 16字节密钥 返回值:解密后的数据、错误
func SM4CBCEncrypt ¶
SM4CBCEncrypt 对数据进行 SM4 CBC 加密(返回加密数据、填充值和错误) 参数:buf - 待加密数据,key - 16字节密钥 返回值:加密后的数据、填充值、错误
func SM4CBCEncryptEx ¶
SM4CBCEncryptEx 对数据进行 SM4 CBC 加密(外部合成buf) 参数:data - 待加密数据(包含totalLen/offset/seq等字段),key - 16字节密钥 返回值:加密后的数据、IV数组、错误
func SM4Decrypt ¶
func SM4DecryptIV ¶
func SM4Encrypt ¶
func SM4EncryptIV ¶
func Serialization ¶
func StringToUnixTimestamp ¶
func UnixNanoTimestamp ¶
func UnixTimestamp ¶
func UnixTimestampToString ¶
func VerifySignature ¶
func VerifySignature(data []byte, sign [64]byte, publicKey *SM2PublicKey, userID []byte) error
func XZCompress ¶
func XZDecompress ¶
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func (*Controller) DelSessionKV ¶
func (c *Controller) DelSessionKV(context *gin.Context, key interface{})
func (*Controller) GetSessionKV ¶
func (c *Controller) GetSessionKV(context *gin.Context, key interface{}) interface{}
func (*Controller) SaveSession ¶
func (c *Controller) SaveSession(context *gin.Context)
func (*Controller) ServiceFinish ¶
func (c *Controller) ServiceFinish(context *gin.Context, status int, res interface{})
func (*Controller) ServiceFinishAsciiJSON ¶
func (c *Controller) ServiceFinishAsciiJSON(context *gin.Context, status int, res interface{})
func (*Controller) ServiceFinishString ¶
func (c *Controller) ServiceFinishString(context *gin.Context, status int, data string)
func (*Controller) SetHttpServer ¶
func (c *Controller) SetHttpServer(web *http.Server)
func (*Controller) SetSessionKV ¶
func (c *Controller) SetSessionKV(context *gin.Context, key interface{}, val interface{})
type ControllerInterface ¶
type ControllerTables ¶
type ControllerTables struct {
List
}
func NewControllerTables ¶
func NewControllerTables() *ControllerTables
func (*ControllerTables) AddController ¶
func (c *ControllerTables) AddController(v interface{})
func (*ControllerTables) AllItem ¶
func (c *ControllerTables) AllItem(f func(value ControllerInterface))
func (*ControllerTables) DelController ¶
func (c *ControllerTables) DelController(v interface{})
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) CountWhere ¶
func (*Database) CreateTable ¶
func (*Database) FindWhereAsc ¶
func (*Database) FindWhereDesc ¶
func (*Database) TableExists ¶
func (*Database) Transactions ¶
type EngineConfig ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func (*Map) DeleteValue ¶
func (p *Map) DeleteValue(key interface{})
type RedisContainer ¶
type RedisContainer struct {
// contains filtered or unexported fields
}
func NewRedisChannel ¶
func (*RedisContainer) ClearDB ¶
func (c *RedisContainer) ClearDB() error
func (*RedisContainer) Close ¶
func (c *RedisContainer) Close()
func (*RedisContainer) Delete ¶
func (c *RedisContainer) Delete(keys ...interface{}) (bool, error)
func (*RedisContainer) ExistsHash ¶
func (c *RedisContainer) ExistsHash(name, field string) (bool, error)
func (*RedisContainer) GetConn ¶
func (c *RedisContainer) GetConn() redis.Conn
func (*RedisContainer) GetDBSize ¶
func (c *RedisContainer) GetDBSize() int64
func (*RedisContainer) GetH ¶
func (c *RedisContainer) GetH(name, field string, v interface{}) (err error)
func (*RedisContainer) GetHM ¶
func (c *RedisContainer) GetHM(name string, fields ...string) ([]interface{}, error)
func (*RedisContainer) ScardInt64s ¶
func (c *RedisContainer) ScardInt64s(name string) (int64, error)
func (*RedisContainer) SetExpireTime ¶
func (c *RedisContainer) SetExpireTime(name string, newSecondsLifeTime int64) error
func (*RedisContainer) SetH ¶
func (c *RedisContainer) SetH(name string, key string, value interface{}) (err error)
func (*RedisContainer) SetHM ¶
func (c *RedisContainer) SetHM(name string, obj interface{}) (err error)
func (*RedisContainer) SetString ¶
func (c *RedisContainer) SetString(name string, v interface{}) error
func (*RedisContainer) Smembers ¶
func (c *RedisContainer) Smembers(name string, v interface{}) (err error)
func (*RedisContainer) StringIncr ¶
func (c *RedisContainer) StringIncr(name string) (int, error)
type RefCounter ¶
type RefCounter struct {
// contains filtered or unexported fields
}
func (*RefCounter) Decrement ¶
func (r *RefCounter) Decrement()
func (*RefCounter) Get ¶
func (r *RefCounter) Get() int
func (*RefCounter) Increment ¶
func (r *RefCounter) Increment()
func (*RefCounter) Set ¶
func (r *RefCounter) Set(value int)
type SM2PrivateKey ¶
type SM2PrivateKey struct {
D *sm2.PrivateKey
}
func LoadSM2PrivateKeyFromPEM ¶
func LoadSM2PrivateKeyFromPEM(filePath string) (*SM2PrivateKey, error)
type SM2PublicKey ¶
func LoadSM2PublicKeyFromCertificate ¶
func LoadSM2PublicKeyFromCertificate(cert *gmX509.Certificate) (*SM2PublicKey, error)
func LoadSM2PubliceyFromBuf ¶
func LoadSM2PubliceyFromBuf(data []byte) (*SM2PublicKey, error)
func LoadSM2PubliceyFromPEM ¶
func LoadSM2PubliceyFromPEM(filePath string) (*SM2PublicKey, error)
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewSchedule ¶
func NewSchedule() *Scheduler
type Semp ¶
type Semp struct {
Ref RefCounter
// contains filtered or unexported fields
}
type ServerConfig ¶
type ServerConfig struct {
Debug bool
// Output 日志输出目标,默认为 os.Stdout
Output io.Writer
// ReadTimeout 读取请求超时时间(秒),默认 30 秒
ReadTimeout int
// WriteTimeout 写入响应超时时间(秒),默认 30 秒
WriteTimeout int
// ReadHeaderTimeout 读取请求头超时时间(秒),默认 10 秒
ReadHeaderTimeout int
// IdleTimeout 长连接空闲超时时间(秒),默认 60 秒(HTTP1.1 Keep-Alive)
IdleTimeout int
// MaxHeaderBytes 请求头最大字节数,默认 1MB
MaxHeaderBytes int
// MaxRequests 最大并发请求数,默认 1000
MaxRequests int
// RequestTimeout 请求处理超时时间(秒),默认 30 秒
RequestTimeout int
// SessionSecret 会话密钥,用于加密 Session Cookie
// 如果为空,会自动生成随机密钥(不推荐生产环境使用)
SessionSecret string
// SecureCookie 是否启用 Secure Cookie(仅 HTTPS)
SecureCookie bool
// SessionMaxAge Session 过期时间(秒),默认 1800 秒(30 分钟)
SessionMaxAge int
}
ServerConfig 定义 HTTP 服务器配置
type Timer ¶
func (*Timer) CreateTickController ¶
func (*Timer) CreateTimeController ¶
func (*Timer) DelTickController ¶
func (*Timer) DelTimeController ¶
func (*Timer) UpdateTimeController ¶
func (*Timer) WaitTimerClose ¶
func (this *Timer) WaitTimerClose()
type Web ¶
type Web struct {
// contains filtered or unexported fields
}
func NewWebEngine ¶
func NewWebEngine(config *ServerConfig) (*Web, error)
func (*Web) AddController ¶
func (web *Web) AddController(v interface{})
func (*Web) GetConfig ¶
func (web *Web) GetConfig() *ServerConfig
func (*Web) GetGinEngine ¶
func (*Web) GetHandler ¶ added in v1.0.10
func (*Web) RegisterController ¶
func (web *Web) RegisterController()
func (*Web) RunServiceTLS ¶
Click to show internal directories.
Click to hide internal directories.