Documentation ¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func InitLog(logger Logger)
- func SetRedisManager(manager RedisManager)
- func Version() string
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warning(args ...interface{})
- func Warningf(format string, args ...interface{})
- type Body
- type BodyDataReader
- type BodyDatawriter
- type BodyGet
- type BodySet
- type BoolCmd
- type BoolSliceCmd
- type Cmd
- type Cmdable
- type Cmder
- type Context
- type ContextAccess
- type ContextApiInfo
- type ContextBeforeMatch
- type ContextProxy
- type CookieReader
- type CookieWriter
- type DurationCmd
- type FileHeader
- type FloatCmd
- type Header
- type HeaderReader
- type HeaderWriter
- type IntCmd
- type Logger
- type Pipeliner
- type PluginAccess
- type PluginBeforeMatch
- type PluginFactory
- type PluginLogProxy
- func (l *PluginLogProxy) Debug(args ...interface{})
- func (l *PluginLogProxy) Debugf(format string, args ...interface{})
- func (l *PluginLogProxy) Error(args ...interface{})
- func (l *PluginLogProxy) Errorf(format string, args ...interface{})
- func (l *PluginLogProxy) Info(args ...interface{})
- func (l *PluginLogProxy) Infof(format string, args ...interface{})
- func (l *PluginLogProxy) Warn(args ...interface{})
- func (l *PluginLogProxy) Warnf(format string, args ...interface{})
- func (l *PluginLogProxy) Warning(args ...interface{})
- func (l *PluginLogProxy) Warningf(format string, args ...interface{})
- type PluginObj
- type PluginProxy
- type PriorityHeader
- type Redis
- type RedisManager
- type Request
- type RequestData
- type RequestReader
- type ResponseReader
- type ResponseWriter
- type SliceCmd
- type StatefulCmdable
- type StatusCmd
- type StatusGet
- type StatusSet
- type Store
- type StoreContainer
- type StringCmd
- type StringIntMapCmd
- type StringSliceCmd
- type StringStringMapCmd
- type StringStructMapCmd
- type TimeCmd
Constants ¶
View Source
const ( MultipartForm = "multipart/form-data" FormData = "application/x-www-form-urlencoded" TEXT = "text/plain" JSON = "application/json" JavaScript = "application/javascript" AppLicationXML = "application/xml" TextXML = "text/xml" Html = "text/html" )
Variables ¶
This section is empty.
Functions ¶
func Debug ¶ added in v0.1.3
func Debug(args ...interface{})
Debug logs a message at level Debug on the standard _logger.
func Debugf ¶ added in v0.1.3
func Debugf(format string, args ...interface{})
Debugf logs a message at level Debug on the standard _logger.
func Error ¶ added in v0.1.3
func Error(args ...interface{})
Error logs a message at level Error on the standard _logger.
func Errorf ¶ added in v0.1.3
func Errorf(format string, args ...interface{})
Errorf logs a message at level Error on the standard _logger.
func Info ¶ added in v0.1.3
func Info(args ...interface{})
Info logs a message at level Info on the standard _logger.
func Infof ¶ added in v0.1.3
func Infof(format string, args ...interface{})
Infof logs a message at level Info on the standard _logger.
func SetRedisManager ¶
func SetRedisManager(manager RedisManager)
func Warn ¶ added in v0.1.3
func Warn(args ...interface{})
Warn logs a message at level Warn on the standard _logger.
func Warnf ¶ added in v0.1.3
func Warnf(format string, args ...interface{})
Warnf logs a message at level Warn on the standard _logger.
Types ¶
type Body ¶
type Body interface { BodyDataReader BodyDatawriter }
type BodyDataReader ¶
type BodyDataReader interface { //Protocol() RequestType ContentType() string //content-Type = application/x-www-form-urlencoded 或 multipart/form-data,与原生request.Form不同,这里不包括 query 参数 BodyForm() (url.Values, error) //content-Type = multipart/form-data 时有效 Files() (map[string]*FileHeader, error) GetForm(key string) string GetFile(key string) (file *FileHeader, has bool) RawBody() ([]byte, error) }
type BodyDatawriter ¶
type BodyDatawriter interface { //设置form数据并将content-type设置 为 application/x-www-form-urlencoded 或 multipart/form-data SetForm(values url.Values) error SetToForm(key, value string) error AddForm(key, value string) error // 会替换掉对应掉file信息,并且将content-type 设置为 multipart/form-data AddFile(key string, file *FileHeader) error // 重置body,会清除掉未处理掉 form和file SetRaw(contentType string, body []byte) }
type BoolSliceCmd ¶
type Cmdable ¶
type Cmdable interface { Ping() StatusCmd Del(keys ...string) IntCmd Unlink(keys ...string) IntCmd Dump(key string) StringCmd Exists(keys ...string) IntCmd Expire(key string, expiration time.Duration) BoolCmd ExpireAt(key string, tm time.Time) BoolCmd Keys(pattern string) StringSliceCmd RandomKey() StringCmd Rename(key, newkey string) StatusCmd RenameNX(key, newkey string) BoolCmd Restore(key string, ttl time.Duration, value string) StatusCmd RestoreReplace(key string, ttl time.Duration, value string) StatusCmd Append(key, value string) IntCmd //BitCountS(key string, Start, End int64) IntCmd BitOpAnd(destKey string, keys ...string) IntCmd BitOpOr(destKey string, keys ...string) IntCmd BitOpXor(destKey string, keys ...string) IntCmd BitOpNot(destKey string, key string) IntCmd BitPos(key string, bit int64, pos ...int64) IntCmd Decr(key string) IntCmd DecrBy(key string, decrement int64) IntCmd Get(key string) StringCmd GetBit(key string, offset int64) IntCmd GetRange(key string, start, end int64) StringCmd GetSet(key string, value interface{}) StringCmd Incr(key string) IntCmd IncrBy(key string, value int64) IntCmd IncrByFloat(key string, value float64) FloatCmd MGet(keys ...string) SliceCmd MSet(pairs ...interface{}) StatusCmd MSetNX(pairs ...interface{}) BoolCmd Set(key string, value interface{}, expiration time.Duration) StatusCmd SetBit(key string, offset int64, value int) IntCmd SetNX(key string, value interface{}, expiration time.Duration) BoolCmd SetXX(key string, value interface{}, expiration time.Duration) BoolCmd SetRange(key string, offset int64, value string) IntCmd StrLen(key string) IntCmd HDel(key string, fields ...string) IntCmd HExists(key, field string) BoolCmd HGet(key, field string) StringCmd HGetAll(key string) StringStringMapCmd HIncrBy(key, field string, incr int64) IntCmd HIncrByFloat(key, field string, incr float64) FloatCmd HKeys(key string) StringSliceCmd HLen(key string) IntCmd HMGet(key string, fields ...string) SliceCmd HMSet(key string, fields map[string]interface{}) StatusCmd HSet(key, field string, value interface{}) BoolCmd HSetNX(key, field string, value interface{}) BoolCmd HVals(key string) StringSliceCmd BLPop(timeout time.Duration, keys ...string) StringSliceCmd BRPop(timeout time.Duration, keys ...string) StringSliceCmd BRPopLPush(source, destination string, timeout time.Duration) StringCmd LIndex(key string, index int64) StringCmd LInsert(key, op string, pivot, value interface{}) IntCmd LInsertBefore(key string, pivot, value interface{}) IntCmd LInsertAfter(key string, pivot, value interface{}) IntCmd LLen(key string) IntCmd LPop(key string) StringCmd LPush(key string, values ...interface{}) IntCmd LPushX(key string, value interface{}) IntCmd LRange(key string, start, stop int64) StringSliceCmd LRem(key string, count int64, value interface{}) IntCmd LSet(key string, index int64, value interface{}) StatusCmd LTrim(key string, start, stop int64) StatusCmd RPop(key string) StringCmd RPopLPush(source, destination string) StringCmd RPush(key string, values ...interface{}) IntCmd RPushX(key string, value interface{}) IntCmd SAdd(key string, members ...interface{}) IntCmd SCard(key string) IntCmd SDiff(keys ...string) StringSliceCmd SDiffStore(destination string, keys ...string) IntCmd SInter(keys ...string) StringSliceCmd SInterStore(destination string, keys ...string) IntCmd SIsMember(key string, member interface{}) BoolCmd SMembers(key string) StringSliceCmd SMembersMap(key string) StringStructMapCmd SMove(source, destination string, member interface{}) BoolCmd SPop(key string) StringCmd SPopN(key string, count int64) StringSliceCmd SRandMember(key string) StringCmd SRandMemberN(key string, count int64) StringSliceCmd SRem(key string, members ...interface{}) IntCmd SUnion(keys ...string) StringSliceCmd SUnionStore(destination string, keys ...string) IntCmd }
type Context ¶
type Context interface { ResponseWriter // 处理返回 StoreContainer // cache RequestId() string FinalTargetServer() string RetryTargetServers() string }
type ContextAccess ¶
type ContextAccess interface { Context // 处理返回 ContextApiInfo // api 信息 Request() RequestReader Proxy() Request // 请求信息,包含原始请求数据以及被更高优先级处理过的结果 }
转发前
type ContextApiInfo ¶
请求基本接口信息
type ContextBeforeMatch ¶
type ContextBeforeMatch interface { Context // 处理返回 Request() RequestReader Proxy() Request // 请求信息,包含原始请求数据以及被更高优先级处理过的结果 }
type ContextProxy ¶
type ContextProxy interface { Context // 处理返回 ContextApiInfo // api 信息 ProxyResponse() ResponseReader // 转发后返回的结果 }
转发后
type CookieReader ¶
type CookieWriter ¶
type DurationCmd ¶
type FileHeader ¶
type FileHeader struct { FileName string Header textproto.MIMEHeader Data []byte }
type Header ¶
type Header interface { HeaderReader HeaderWriter }
type HeaderReader ¶
type HeaderWriter ¶
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Warning(args ...interface{}) Error(args ...interface{}) }
type PluginAccess ¶
type PluginAccess interface {
Access(ctx ContextAccess) (isContinue bool, e error)
}
type PluginBeforeMatch ¶
type PluginBeforeMatch interface {
BeforeMatch(ctx ContextBeforeMatch) (isContinue bool, e error)
}
type PluginFactory ¶
type PluginFactory interface {
Create(config string, clusterName string, updateTag string, strategyId string, apiId int) (*PluginObj, error)
}
定义插件实现函数
type PluginLogProxy ¶ added in v0.1.3
type PluginLogProxy struct {
// contains filtered or unexported fields
}
func (*PluginLogProxy) Debug ¶ added in v0.1.3
func (l *PluginLogProxy) Debug(args ...interface{})
func (*PluginLogProxy) Debugf ¶ added in v0.1.3
func (l *PluginLogProxy) Debugf(format string, args ...interface{})
func (*PluginLogProxy) Error ¶ added in v0.1.3
func (l *PluginLogProxy) Error(args ...interface{})
func (*PluginLogProxy) Errorf ¶ added in v0.1.3
func (l *PluginLogProxy) Errorf(format string, args ...interface{})
func (*PluginLogProxy) Info ¶ added in v0.1.3
func (l *PluginLogProxy) Info(args ...interface{})
func (*PluginLogProxy) Infof ¶ added in v0.1.3
func (l *PluginLogProxy) Infof(format string, args ...interface{})
func (*PluginLogProxy) Warn ¶ added in v0.1.3
func (l *PluginLogProxy) Warn(args ...interface{})
func (*PluginLogProxy) Warnf ¶ added in v0.1.3
func (l *PluginLogProxy) Warnf(format string, args ...interface{})
func (*PluginLogProxy) Warning ¶ added in v0.1.3
func (l *PluginLogProxy) Warning(args ...interface{})
func (*PluginLogProxy) Warningf ¶ added in v0.1.3
func (l *PluginLogProxy) Warningf(format string, args ...interface{})
type PluginObj ¶
type PluginObj struct { BeforeMatch PluginBeforeMatch Access PluginAccess Proxy PluginProxy }
type PluginProxy ¶
type PluginProxy interface {
Proxy(ctx ContextProxy) (isContinue bool, e error)
}
type PriorityHeader ¶
type PriorityHeader interface { HeaderReader // 读已经设置的header HeaderWriter // 设置header // 非Priority的header会被 proxy 的同名项替换掉, Set() Header // 这里设置的header会替换掉proxy的内容 Append() Header // 这里设置的header会追加到proxy的内容 }
带优先的header
type Redis ¶
type Redis interface { Cmdable Pipeline() Pipeliner Pipelined(fn func(Pipeliner) error) ([]Cmder, error) }
func GetRedisByName ¶
type RedisManager ¶
type Request ¶
type Request interface { CookieReader HeaderReader HeaderWriter CookieWriter Body Querys() url.Values TargetServer() string TargetURL() string }
用于组装转发的request
type RequestData ¶
type RequestReader ¶
type RequestReader interface { CookieReader HeaderReader RequestData }
原始请求数据的读
type ResponseReader ¶
type ResponseReader interface { CookieReader HeaderReader BodyGet StatusGet }
读取转发结果的response
type ResponseWriter ¶
type ResponseWriter interface { PriorityHeader CookieReader // 已经设置的cookie CookieWriter // 设置返回的cookie StatusGet StatusSet // 设置返回状态 BodySet // 设置返回内容 BodyGet }
返回给client端的
type StatefulCmdable ¶
type StoreContainer ¶
type StoreContainer interface { Store() Store // 私有存储 SetCache(name string, value interface{}) GetCache(name string) (value interface{}, has bool) }
存储容器
type StringIntMapCmd ¶
type StringSliceCmd ¶
type StringStringMapCmd ¶
type StringStructMapCmd ¶
Click to show internal directories.
Click to hide internal directories.