mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 17:41:57 +08:00
Feat: sign http request / read running mode from config file
This commit is contained in:
22
pkg/serializer/auth.go
Normal file
22
pkg/serializer/auth.go
Normal 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)
|
||||
}
|
||||
13
pkg/serializer/auth_test.go
Normal file
13
pkg/serializer/auth_test.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user