Documentation ¶
Index ¶
- Constants
- Variables
- func AESDecrypt(encryptedData string) string
- func AESEncrypt(origData string) string
- func DecryptAESCBCBase64(encryptedData string, key string) (string, error)
- func DecryptAes(encryptedData string, key string, original interface{}) error
- func DoHttp(method string, url string, headers map[string]string, body *bytes.Buffer) ([]byte, int, error)
- func DoHttpDeleteOApi(path protocol.OpenApiPath, headers map[string]string, params map[string]string) ([]byte, int, error)
- func DoHttpGetOApi(path protocol.OpenApiPath, headers map[string]string, params map[string]string) ([]byte, int, error)
- func DoHttpPatchApi(path protocol.OpenApiPath, headers map[string]string, data interface{}) ([]byte, int, error)
- func DoHttpPostOApi(path protocol.OpenApiPath, headers map[string]string, data interface{}) ([]byte, int, error)
- func DoHttpPutOApi(path protocol.OpenApiPath, headers map[string]string, data interface{}) ([]byte, int, error)
- func EncryptAESCBCBase64(originalData string, key string) (string, error)
- func EncryptAes(original interface{}, key string) (string, error)
- func FlushLogger()
- func GetAESEncryptKey() string
- func GetMd5(src io.Reader) string
- func GetMd5ByBytes(src []byte) string
- func GetOpenPlatformHost() string
- func InitAESEncryptKey(encryptKey string)
- func InitLogger(log LogInterface, option interface{})
- func NewHeaderJson() map[string]string
- func NewHeaderToken(accessToken string) map[string]string
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(originalData []byte) ([]byte, error)
- func RecoverPanic(ctx context.Context)
- func ReplaceFeishuHost(host string)
- func ReplaceLarkHost(host string)
- func SetFeishu()
- func SetLark()
- type CommonLogger
- type CommonLoggerOption
- type DBClient
- type DefaultRedisClient
- type ErrCodeMsg
- type LogEntry
- type LogInterface
Constants ¶
View Source
const ( HTTPMethodGet = "GET" HTTPMethodHead = "HEAD" HTTPMethodPost = "POST" HTTPMethodPut = "PUT" HTTPMethodPatch = "PATCH" HTTPMethodDelete = "DELETE" HTTPMethodConnect = "CONNECT" HTTPMethodOptions = "OPTIONS" HTTPMethodTrace = "TRACE" )
Common HTTP methods.
View Source
const (
HTTPCodeOK = 200
)
Common HTTP status code.
Variables ¶
View Source
var ( Success = &ErrCodeMsg{Code: 0, Message: "success"} // 1. common 1000 - 1999 ErrJsonMarshal = &ErrCodeMsg{Code: 1000, Message: "json marshal error"} ErrJsonUnmarshal = &ErrCodeMsg{Code: 1001, Message: "json unmarshal error"} ErrOpenApiFailed = &ErrCodeMsg{Code: 1002, Message: "open api failed"} ErrOpenApiReturnError = &ErrCodeMsg{Code: 1003, Message: "open api return error"} ErrAppConfNotFound = &ErrCodeMsg{Code: 1004, Message: "app config not found"} ErrHttpCode = &ErrCodeMsg{Code: 1005, Message: "http return not 200 "} // 2. auth 2000 - 2999 ErrAppTokenNotFound = &ErrCodeMsg{Code: 2000, Message: "auth app token not found"} ErrAppTicketNotFound = &ErrCodeMsg{Code: 2001, Message: "auth app ticket not found"} ErrGetInternalTenantAccessToken = &ErrCodeMsg{Code: 2002, Message: "auth get internal tenant access token error"} ErrGetISVTenantAccessToken = &ErrCodeMsg{Code: 2003, Message: "auth get ISV tenant access token error"} ErrGetAppAccessToken = &ErrCodeMsg{Code: 2004, Message: "auth get app access token error"} ErrGetInternalAppAccessToken = &ErrCodeMsg{Code: 2005, Message: "auth get internal app access token error"} ErrGetISVAppAccessToken = &ErrCodeMsg{Code: 2006, Message: "auth get ISV app access token error"} ErrRespDataIsNil = &ErrCodeMsg{Code: 2007, Message: "auth response data is nil"} ErrTicketManagerNotInit = &ErrCodeMsg{Code: 2008, Message: "auth ticket manager not init"} ErrSetAppTicketFailed = &ErrCodeMsg{Code: 2009, Message: "auth set app ticket failed"} // 3. message 3000 - 3999 ErrSendMsgParams = &ErrCodeMsg{Code: 3000, Message: "send msg params error"} ErrPostFormParams = &ErrCodeMsg{Code: 3001, Message: "postform params error"} ErrImageParams = &ErrCodeMsg{Code: 3002, Message: "get_imagekey params error"} ErrGenBinImageFailed = &ErrCodeMsg{Code: 3003, Message: "generate binary image error"} ErrGetImageBinDataParams = &ErrCodeMsg{Code: 3004, Message: "get_image_bin_data params error"} ErrCardUpdateParams = &ErrCodeMsg{Code: 3100, Message: "update card params error"} // 4. chat and bot 4000 - 4999 ErrChatParams = &ErrCodeMsg{Code: 4000, Message: "chat params error"} ErrCreateChatParams = &ErrCodeMsg{Code: 4001, Message: "create chat params error"} ErrUpdateChatInfoParams = &ErrCodeMsg{Code: 4002, Message: "update chat info params error"} ErrAddUserToChatParams = &ErrCodeMsg{Code: 4003, Message: "add user to chat params error"} ErrDeleteUserFromChatParams = &ErrCodeMsg{Code: 4004, Message: "delete user from chat params error"} ErrDisbandChatParams = &ErrCodeMsg{Code: 4005, Message: "disband chat params error"} ErrGetBotInfoParams = &ErrCodeMsg{Code: 4006, Message: "getBotInfo params error"} ErrAddBotToChatParams = &ErrCodeMsg{Code: 4007, Message: "addBotToChat params error"} ErrRemoveBotFromChatParams = &ErrCodeMsg{Code: 4008, Message: "removeBotFromChat params error"} // 5. event 5000 - 5999 ErrEventTypeRegister = &ErrCodeMsg{Code: 5000, Message: "event type register handler error"} ErrEventManagerNotInit = &ErrCodeMsg{Code: 5001, Message: "event not init"} ErrEventParams = &ErrCodeMsg{Code: 5002, Message: "event params error"} ErrEventDecrypt = &ErrCodeMsg{Code: 5003, Message: "event decrypt error"} ErrEventGetBase = &ErrCodeMsg{Code: 5004, Message: "event get event base error"} ErrEventVeriToken = &ErrCodeMsg{Code: 5005, Message: "event veri token error"} ErrEventTypeUnknown = &ErrCodeMsg{Code: 5006, Message: "event unknown callback type"} ErrEventGetJsonEvent = &ErrCodeMsg{Code: 5007, Message: "event get event body error"} ErrEventGetJsonType = &ErrCodeMsg{Code: 5008, Message: "event get event type error"} ErrEventGetJsonAppID = &ErrCodeMsg{Code: 5009, Message: "event get app id error"} ErrEventAppIDNotMatch = &ErrCodeMsg{Code: 5010, Message: "event app id not match error"} ErrEventAppIDUnregistered = &ErrCodeMsg{Code: 5011, Message: "event appid_handler unregistered"} ErrEventTypeUnregistered = &ErrCodeMsg{Code: 5012, Message: "event notification_type_handler unregistered"} ErrEventHandlerIsNil = &ErrCodeMsg{Code: 5013, Message: "event handler not found"} ErrEventHandlerFailed = &ErrCodeMsg{Code: 5014, Message: "event handle function error"} ErrBotRecvMsgRegister = &ErrCodeMsg{Code: 5100, Message: "botRecvMsg registered error"} ErrBotRecvMsgMsgTypeJson = &ErrCodeMsg{Code: 5101, Message: "botRecvMsg get msg_type error"} ErrBotRecvMsgAppIDJson = &ErrCodeMsg{Code: 5102, Message: "botRecvMsg get app_id error"} ErrBotRecvMsgHandlerNoFound = &ErrCodeMsg{Code: 5103, Message: "botRecvMsg cannot find handler"} ErrBotRecvMsgHandlerFailed = &ErrCodeMsg{Code: 5104, Message: "botRecvMsg call handler failed"} ErrCardParams = &ErrCodeMsg{Code: 5200, Message: "card action callback params error"} ErrCardMethodRegister = &ErrCodeMsg{Code: 5201, Message: "card action method has not registered yet"} ErrCardManagerNotInit = &ErrCodeMsg{Code: 5202, Message: "card action handler need be init"} ErrCardVeriTokenInvalid = &ErrCodeMsg{Code: 5203, Message: "card action callback veri token invalid"} ErrCardSignatureInvalid = &ErrCodeMsg{Code: 5204, Message: "card action callback signature invalid"} ErrCardWithoutMethod = &ErrCodeMsg{Code: 5205, Message: "card action callback has no method"} ErrCardWithoutSessionID = &ErrCodeMsg{Code: 5206, Message: "card action callback has no session id"} ErrCardMetaInvalid = &ErrCodeMsg{Code: 5207, Message: "card action callback meta invalid"} ErrCardHandlerIsNil = &ErrCodeMsg{Code: 5208, Message: "card action handler not found"} ErrCardHandlerFailed = &ErrCodeMsg{Code: 5209, Message: "card action handler failed"} // 6. authentication 6000 - 6999 ErrValidateParams = &ErrCodeMsg{Code: 6000, Message: "authentication-login params error"} ErrAuthParams = &ErrCodeMsg{Code: 6001, Message: "authentication-auth params error"} ErrMinaCodeGetParams = &ErrCodeMsg{Code: 6002, Message: "mini-program codeToSession get params error"} ErrMinaSetAuth = &ErrCodeMsg{Code: 6003, Message: "mini-program set auth-user-info error"} ErrMinaGetAuth = &ErrCodeMsg{Code: 6004, Message: "mini-program get auth-user-info error"} ErrMinaSessionInvalid = &ErrCodeMsg{Code: 6005, Message: "mini-program session invalid"} ErrLogoutParams = &ErrCodeMsg{Code: 6006, Message: "authentication-logout params error"} )
Functions ¶
func AESDecrypt ¶
func AESEncrypt ¶
func DecryptAESCBCBase64 ¶
DecryptAESCBCBase64 AES CBC base64URLEncoding
func DecryptAes ¶
DecryptAes aes decypt
func DoHttpDeleteOApi ¶
func DoHttpDeleteOApi(path protocol.OpenApiPath, headers map[string]string, params map[string]string) ([]byte, int, error)
DoHttpDeleteOApi open platform DELETE http
func DoHttpGetOApi ¶
func DoHttpGetOApi(path protocol.OpenApiPath, headers map[string]string, params map[string]string) ([]byte, int, error)
DoHttpGetOApi open platform GET http
func DoHttpPatchApi ¶
func DoHttpPatchApi(path protocol.OpenApiPath, headers map[string]string, data interface{}) ([]byte, int, error)
DoHttpPatchApi open platform PATCH http
func DoHttpPostOApi ¶
func DoHttpPostOApi(path protocol.OpenApiPath, headers map[string]string, data interface{}) ([]byte, int, error)
DoHttpPostOApi open platform POST http
func DoHttpPutOApi ¶
func DoHttpPutOApi(path protocol.OpenApiPath, headers map[string]string, data interface{}) ([]byte, int, error)
DoHttpPutOApi open platform PUT http
func EncryptAESCBCBase64 ¶
EncryptAESCBCBase64 AES CBC base64URLEncoding
func EncryptAes ¶
EncryptAes aes encrypt
func FlushLogger ¶
func FlushLogger()
func GetAESEncryptKey ¶
func GetAESEncryptKey() string
func GetMd5ByBytes ¶
func GetOpenPlatformHost ¶
func GetOpenPlatformHost() string
GetOpenPlatformHost outside mainland China use https://open.larksuite.com , in Mainland China use https://open.feishu.cn
func InitAESEncryptKey ¶
func InitAESEncryptKey(encryptKey string)
func InitLogger ¶
func InitLogger(log LogInterface, option interface{})
default demo: common.InitLogger(common.NewCommonLogger(), common.DefaultOption())
func NewHeaderJson ¶
func NewHeaderToken ¶
func RecoverPanic ¶
func ReplaceFeishuHost ¶
func ReplaceFeishuHost(host string)
func ReplaceLarkHost ¶
func ReplaceLarkHost(host string)
Types ¶
type CommonLogger ¶
func NewCommonLogger ¶
func NewCommonLogger() *CommonLogger
func (*CommonLogger) Init ¶
func (l *CommonLogger) Init(op interface{})
func (*CommonLogger) RegistFieldName ¶
func (l *CommonLogger) RegistFieldName(ctxFieldName, logFieldName string) (oldLogFieldName string)
type CommonLoggerOption ¶
type CommonLoggerOption struct { Level logrus.Level TimestampFormat string FullTimestamp bool HighSpeedMode bool OnFile bool FilePathMap lfshook.PathMap }
func DefaultOption ¶
func DefaultOption() *CommonLoggerOption
type DefaultRedisClient ¶
type ErrCodeMsg ¶
func (ErrCodeMsg) Error ¶
func (e ErrCodeMsg) Error() error
func (ErrCodeMsg) ErrorWithExtErr ¶
func (e ErrCodeMsg) ErrorWithExtErr(err error) error
func (ErrCodeMsg) ErrorWithExtStr ¶
func (e ErrCodeMsg) ErrorWithExtStr(str string) error
func (ErrCodeMsg) String ¶
func (e ErrCodeMsg) String() string
func (ErrCodeMsg) StringWithExtErr ¶
func (e ErrCodeMsg) StringWithExtErr(extErr error) string
type LogEntry ¶
type LogEntry interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Debugln(args ...interface{}) Infoln(args ...interface{}) Warnln(args ...interface{}) Errorln(args ...interface{}) Fatalln(args ...interface{}) }
type LogInterface ¶
Click to show internal directories.
Click to hide internal directories.