Documentation ¶
Index ¶
- Constants
- Variables
- func Collect()
- func GetAccessKey(ctx context.Context) (accessKey string, found bool)
- func GetCallerLevelFromContext(ctx context.Context) (int, error)
- func GetCallerLevelFromMd(md metadata.MD) (level int, err error)
- func GetIncomingHeader(ctx context.Context, extra ...metadata.MD) metadata.MD
- func GetIncomingUserId(ctx context.Context) (userId *dt.ID, err error)
- func GetOutgoingHeader(ctx context.Context, extra ...metadata.MD) metadata.MD
- func GetTokenFromContext(ctx context.Context) (token string, err error)
- func IsValidSignMethod(signMethod SignMethod) bool
- func MergeMetadata(base metadata.MD, md ...metadata.MD) metadata.MD
- func MergeRequestHeaderFromMetadata(req *http.Request, md ...metadata.MD)
- func ParseJwt(ctx context.Context) (*jwt.Claims, error)
- func Retry(f func() (isEnd bool, err error), times ...int) error
- func RpcCall(ctx context.Context, host string, queryPath string, data proto.Message, ...) (code int, err error)
- func SetIncomingUserId(ctx context.Context, userId *dt.ID) (next context.Context)
- type EntrypointDispatcher
- type RandomEntrypointDispatcher
- type RpcSignContentHandler
- type Sha256SignHandler
- type SignMethod
Constants ¶
View Source
const ( SignMethodUnknown = SignMethod("unknown") SignMethodMd5 = SignMethod("md5") SignMethodSha1 = SignMethod("sha1") SignMethodSha256 = SignMethod("sha256") SignMethodSha512 = SignMethod("sha512") )
View Source
const ( HeaderContextCallerService = "X-Rpc-Caller-Service" HeaderContextCallerLevel = "X-Rpc-Caller-Level" HeaderContextAccessKey = "X-Rpc-Access-Key" HeaderContextToken = "X-Rpc-Token" HeaderContextSign = "X-Rpc-Sign" HeaderContextSignMethod = "X-Rpc-Sign-Method" HeaderContextUserId = "X-Rpc-User-Id" HeaderContextTimestamp = "X-Rpc-Timestamp" )
View Source
const ( DefaultRpcPort = 20443 DefaultHttpPort = 20080 DefaultCallerLevel = 1000 SignExpiresInSeconds = 15 )
View Source
const ( DateTimeLayout = "2006-01-02 15:04:05" DateLayout = "2006-01-02" TimeLayout = "15:04:05" LogTimestamp = "2006-01-02 15:04:05.000" )
View Source
const Version = "v0.0.2"
Variables ¶
View Source
var ( MdContextCallerService = strings.ToLower(HeaderContextCallerService) MdContextCallerLevel = strings.ToLower(HeaderContextCallerLevel) MdContextAccessKey = strings.ToLower(HeaderContextAccessKey) MdContextToken = strings.ToLower(HeaderContextToken) MdContextSign = strings.ToLower(HeaderContextSign) MdContextSignMethod = strings.ToLower(HeaderContextSignMethod) MdContextUserId = strings.ToLower(HeaderContextUserId) MdContextTimestamp = strings.ToLower(HeaderContextTimestamp) )
Functions ¶
func GetIncomingHeader ¶
func GetOutgoingHeader ¶
func IsValidSignMethod ¶
func IsValidSignMethod(signMethod SignMethod) bool
Types ¶
type EntrypointDispatcher ¶
type EntrypointDispatcher interface {
SelectOne() string
}
func NewRandomEntrypointDispatcher ¶
func NewRandomEntrypointDispatcher(entrypointCandidates []string) EntrypointDispatcher
type RandomEntrypointDispatcher ¶
type RandomEntrypointDispatcher struct {
// contains filtered or unexported fields
}
func (*RandomEntrypointDispatcher) SelectOne ¶
func (t *RandomEntrypointDispatcher) SelectOne() string
type RpcSignContentHandler ¶
type RpcSignContentHandler interface { Sum(data []byte) (method SignMethod, signResult string, err error) GetAccessKey() string }
func NewDefaultSignHandler ¶
func NewDefaultSignHandler(accessKey string, secret string) RpcSignContentHandler
type Sha256SignHandler ¶
type Sha256SignHandler struct {
// contains filtered or unexported fields
}
func (*Sha256SignHandler) GetAccessKey ¶
func (t *Sha256SignHandler) GetAccessKey() string
func (*Sha256SignHandler) Sum ¶
func (t *Sha256SignHandler) Sum(data []byte) (method SignMethod, signResult string, err error)
type SignMethod ¶
type SignMethod string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cos
Code generated by yc@v0.0.1
|
Code generated by yc@v0.0.1 |
cos/db
Code generated by yc@v0.0.1.
|
Code generated by yc@v0.0.1. |
cos/server
Code generated by yc@v0.0.1
|
Code generated by yc@v0.0.1 |
cos/server/http
Code generated by yc@v0.0.1.
|
Code generated by yc@v0.0.1. |
Click to show internal directories.
Click to hide internal directories.