Feat: sign http request / read running mode from config file

This commit is contained in:
HFO4
2019-12-23 13:27:18 +08:00
parent fd7b6e33c8
commit 90827b2441
13 changed files with 199 additions and 45 deletions

22
pkg/serializer/auth.go Normal file
View File

@@ -0,0 +1,22 @@
package serializer
import "encoding/json"
// RequestRawSign 待签名的HTTP请求
type RequestRawSign struct {
Path string
Policy string
Body string
}
// NewRequestSignString 返回JSON格式的待签名字符串
// TODO 测试
func NewRequestSignString(path, policy, body string) string {
req := RequestRawSign{
Path: path,
Policy: policy,
Body: body,
}
res, _ := json.Marshal(req)
return string(res)
}

View File

@@ -0,0 +1,13 @@
package serializer
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestNewRequestSignString(t *testing.T) {
asserts := assert.New(t)
sign := NewRequestSignString("1", "2", "3")
asserts.NotEmpty(sign)
}