Documentation ¶
Index ¶
- Variables
- func CacheAlive() error
- func CacheDelete(key string) error
- func CacheDial(address, password string, dbnum int) (redis.Conn, error)
- func CacheGet(key string) ([]byte, error)
- func CacheGetEncoded(key string, value interface{}) error
- func CacheInit(servers []string, password string, dbnum int) error
- func CacheList(patern string) ([]string, error)
- func CacheProlong(key string, timeout int64) error
- func CachePublish(channel string, value interface{}) error
- func CacheSet(key string, value interface{}, timeout int64) error
- func CacheSetEncoded(key string, value interface{}, timeout int64) error
- func CacheSubscribe(channel string) redis.PubSubConn
- func Error(w http.ResponseWriter, r *http.Request, code int, message string)
- func ErrorLog(w http.ResponseWriter, r *http.Request, code int, message string, ...)
- func ErrorLogErr(w http.ResponseWriter, r *http.Request, code int, message string, err error)
- func IsHexString(str string) bool
- func IsLangID(str string) bool
- func IsRedisMaster(c redis.Conn) (bool, []interface{}, error)
- func IsUUID(str string) bool
- func OK(w http.ResponseWriter, r *http.Request, j interface{})
- func Request2json(request *http.Request, v interface{}) error
- func SessionGetUser(r *http.Request) (int64, error)
- func SessionLogin(uid int64, w http.ResponseWriter) (string, error)
- func SessionLogout(w http.ResponseWriter, r *http.Request)
- func SessionLogoutAllUserSessions(uid int64) error
- func SessionNew(data interface{}, w http.ResponseWriter) (string, error)
- func SlackInit(url, name, icon, channel string)
- func SlackLog(message string) error
- func Sleepy1Result(result interface{}) (int, interface{}, http.Header)
- func Sleepy1in1Map(result interface{}, key string) (int, interface{}, http.Header)
- func Sleepy1inNMap(result interface{}, key string) (int, interface{}, http.Header)
- func SleepyError(status int, msg string, request *http.Request) (int, interface{}, http.Header)
- func SleepyStError(msg string, request *http.Request) (int, interface{}, http.Header)
- func SleepyStOk() (int, interface{}, http.Header)
- func SleepyStResult(result interface{}, key string) (int, interface{}, http.Header)
- func WriteRawJSON(w http.ResponseWriter, r *http.Request, message string)
- type SessionInfo
Constants ¶
This section is empty.
Variables ¶
var JSON = http.Header{"Content-type": {"application/json"}, "Cache-Control": {"no-cache, no-store, must-revalidate"}, "Pragma": {"no-cache"}}
JSON http Content-type header
Functions ¶
func CacheGetEncoded ¶
CacheGetEncoded returns decoded gob value for key
func CacheProlong ¶
CacheProlong set expire of key
func CachePublish ¶
CachePublish publish value to redis channel
func CacheSetEncoded ¶
CacheSetEncoded sets key/value using gob enoder
func CacheSubscribe ¶
func CacheSubscribe(channel string) redis.PubSubConn
CacheSubscribe subscribes to redis channel
func ErrorLogErr ¶
ErrorLogErr func ouputs error message in json format and logs error
func IsRedisMaster ¶
IsRedisMaster returns true, nil, []interface{} if connected to redis master
func OK ¶
func OK(w http.ResponseWriter, r *http.Request, j interface{})
OK func simple outputs json with 200 status
func Request2json ¶
Request2json reads requests body and unmarshals json from it
func SessionGetUser ¶
SessionGetUser returns all user Id based on session id
func SessionLogin ¶
func SessionLogin(uid int64, w http.ResponseWriter) (string, error)
SessionLogin creates session and saves uid
func SessionLogout ¶
func SessionLogout(w http.ResponseWriter, r *http.Request)
SessionLogout removed sid cookie and data from redis
func SessionLogoutAllUserSessions ¶
SessionLogoutAllUserSessions reads all stored sessions and delete ones belong to user
func SessionNew ¶
func SessionNew(data interface{}, w http.ResponseWriter) (string, error)
SessionNew returns id of newly created session
func SlackInit ¶
func SlackInit(url, name, icon, channel string)
SlackInit function sets slack team, token and channel for logging
func Sleepy1Result ¶
Sleepy1Result warps sigle value into array for rest/sleepy
func Sleepy1in1Map ¶
Sleepy1in1Map warps sigle value into map for rest/sleepy
func Sleepy1inNMap ¶
Sleepy1inNMap warps sigle value into array in map for rest/sleepy
func SleepyError ¶
SleepyError function outputs json error and needed values for sleepy framework
func SleepyStError ¶
SleepyStError function outputs structured json error for sleepy framework
func SleepyStOk ¶
SleepyStOk return just "status:ok" result
func SleepyStResult ¶
SleepyStResult warps sigle value into {"status": status, key:result}
func WriteRawJSON ¶
func WriteRawJSON(w http.ResponseWriter, r *http.Request, message string)
WriteRawJSON func ouputs message with 200 status
Types ¶
type SessionInfo ¶
type SessionInfo struct {
UID int64 `msg:"uid"`
}
SessionInfo is type stored to redis
func (SessionInfo) MarshalMsg ¶
func (z SessionInfo) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*SessionInfo) UnmarshalMsg ¶
func (z *SessionInfo) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler