Documentation
¶
Index ¶
- Constants
- func BCryptMatchPasswd(hashPasswd, passwd string) bool
- func BcryptHashPasswd(passwd string) (string, error)
- func HttpClientPost(url string, transport http.RoundTripper, req interface{}) ([]byte, error)
- func HttpClientPostBytes(url string, transport http.RoundTripper, b []byte) ([]byte, error)
- func HttpResponse(w http.ResponseWriter, res *MessageRsp) error
- func HttpTransportGet(url string, transport http.RoundTripper, w http.ResponseWriter) ([]byte, error)
- func HttpTransportPost(url string, transport http.RoundTripper, obj interface{}, ...) ([]byte, error)
- func HttpTransportPostBytes(url string, transport http.RoundTripper, body []byte, w http.ResponseWriter) ([]byte, error)
- func InitLog(logLevel, logFile string, enableConsole bool) error
- func MiddlewareTimeElapsed(next http.Handler) http.Handler
- type DBComponent
- type DBConfig
- type LogFormat
- type MessageRsp
- type RedisComponent
- type SRClient
- type SRClientArgs
- type Session
- type SessionComponent
- type SessionHandler
- func (this *SessionHandler) GenSession(userID string) (*Session, error)
- func (this *SessionHandler) GenSessionID() (string, error)
- func (this *SessionHandler) GenToken(plainText string) (string, error)
- func (this *SessionHandler) GenerateRandomBytes(n int) ([]byte, error)
- func (this *SessionHandler) MiddlewareSessionCheck(next http.Handler) http.Handler
- func (this *SessionHandler) SaveSession(session *Session) error
- func (this *SessionHandler) UpdateSession(session *Session) error
- type SrClientComponent
Constants ¶
View Source
const ( ERROR_OK = 0 ERROR_COMMON = -1 // 通用错误 ERROR_INTERNAL = 501 // 内部错误 ERROR_AUTH = 502 // 认证错误(无法获取session, token过期等) ERROR_BAD_REQ = 503 // 客户端错误的请求 ERROR_CAPTCHA = 504 // 验证码错误 )
View Source
const ( SESSION_USER = "uid" SESSION_ID = "session" SESSION_TOKEN = "token" )
View Source
const ( ServiceStatus_Pass = 1 ServiceStatus_ReadyToOffline = 2 )
Variables ¶
This section is empty.
Functions ¶
func BCryptMatchPasswd ¶
func BcryptHashPasswd ¶
func HttpClientPost ¶
func HttpClientPost(url string, transport http.RoundTripper, req interface{}) ([]byte, error)
func HttpClientPostBytes ¶
func HttpResponse ¶
func HttpResponse(w http.ResponseWriter, res *MessageRsp) error
func HttpTransportGet ¶
func HttpTransportGet(url string, transport http.RoundTripper, w http.ResponseWriter) ([]byte, error)
func HttpTransportPost ¶
func HttpTransportPost(url string, transport http.RoundTripper, obj interface{}, w http.ResponseWriter) ([]byte, error)
func HttpTransportPostBytes ¶
func HttpTransportPostBytes(url string, transport http.RoundTripper, body []byte, w http.ResponseWriter) ([]byte, error)
Types ¶
type DBComponent ¶
type DBComponent struct {
// contains filtered or unexported fields
}
func GetDBComponent ¶
func GetDBComponent() *DBComponent
func (*DBComponent) AddDBMysql ¶
func (this *DBComponent) AddDBMysql(name string, cfg DBConfig) error
func (*DBComponent) GetEngine ¶
func (this *DBComponent) GetEngine(name string) (*xorm.Engine, error)
func (*DBComponent) InitEngines ¶
func (this *DBComponent) InitEngines(dbMap map[string]DBConfig) error
type MessageRsp ¶
type MessageRsp struct {
Code int `json:"code,omitempty"`
ErrMsg string `json:"msg,omitempty"`
Data interface{} `json:"data,omitempty"`
}
func HttpSRPost ¶
func HttpSRPost(serviceName, urlPath string, transport http.RoundTripper, req interface{}, rspData interface{}) (*MessageRsp, error)
http service registry post
type RedisComponent ¶
func GetRedisComponent ¶
func GetRedisComponent() *RedisComponent
type SRClient ¶
type SRClient struct {
ClientSD *srd.ServiceDiscoveryClient
ClientLB *clb.ClientLoadBalancer
ServiceStatus int
}
func NewSRClient ¶
func NewSRClient(args *SRClientArgs) (*SRClient, error)
type SRClientArgs ¶
type SessionComponent ¶
type SessionComponent struct {
Handler *SessionHandler
}
func GetSessionComponent ¶
func GetSessionComponent() *SessionComponent
type SessionHandler ¶
func NewSessionHandler ¶
func NewSessionHandler(redisClient *redis.Client, sessionExpireSecond int) *SessionHandler
func (*SessionHandler) GenSession ¶
func (this *SessionHandler) GenSession(userID string) (*Session, error)
generate and save user session
func (*SessionHandler) GenSessionID ¶
func (this *SessionHandler) GenSessionID() (string, error)
func (*SessionHandler) GenToken ¶
func (this *SessionHandler) GenToken(plainText string) (string, error)
func (*SessionHandler) GenerateRandomBytes ¶
func (this *SessionHandler) GenerateRandomBytes(n int) ([]byte, error)
func (*SessionHandler) MiddlewareSessionCheck ¶
func (this *SessionHandler) MiddlewareSessionCheck(next http.Handler) http.Handler
func (*SessionHandler) SaveSession ¶
func (this *SessionHandler) SaveSession(session *Session) error
func (*SessionHandler) UpdateSession ¶
func (this *SessionHandler) UpdateSession(session *Session) error
refresh session
type SrClientComponent ¶
type SrClientComponent struct {
Client *SRClient
}
func GetSrClientComponent ¶
func GetSrClientComponent() *SrClientComponent
func (*SrClientComponent) Init ¶
func (this *SrClientComponent) Init(args *SRClientArgs) error
Click to show internal directories.
Click to hide internal directories.