Skip to content

Commit

Permalink
refactor(创世云): 增加A类型签名
Browse files Browse the repository at this point in the history
  • Loading branch information
storezhang committed Mar 31, 2023
1 parent cc9911d commit cc370e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions changcache.go → changcache_a.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import (
"github.com/goexl/cryptor"
)

var _ signer = (*chuangcache)(nil)
var _ signer = (*chuangcacheA)(nil)

type chuangcache struct {
type chuangcacheA struct {
pattern string
token string
}

func newChuangcache(token string) *chuangcache {
return &chuangcache{
func newChuangcacheA(token string) *chuangcacheA {
return &chuangcacheA{
pattern: "%s%s%d",
token: token,
}
}

func (c *chuangcache) sign(url *url.URL) (err error) {
func (ca *chuangcacheA) sign(url *url.URL) (err error) {
now := time.Now().Unix()
key := fmt.Sprintf(c.pattern, c.token, url.Path, now)
key := fmt.Sprintf(ca.pattern, ca.token, url.Path, now)
query := url.Query()
query.Add("KEY1", cryptor.New(key).Md5().Hex())
query.Add("KEY2", "timestamp")
Expand Down
4 changes: 2 additions & 2 deletions chuangcache_signer_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func (csb *chuangcacheSignerBuilder) Domain(domain string) *chuangcacheSignerBui
return csb
}

func (csb *chuangcacheSignerBuilder) Token(token string) *chuangcacheSignerBuilder {
csb.signer = newChuangcache(token)
func (csb *chuangcacheSignerBuilder) A(token string) *chuangcacheSignerBuilder {
csb.signer = newChuangcacheA(token)

return csb
}
Expand Down

0 comments on commit cc370e0

Please sign in to comment.