mirror of
https://github.com/fumiama/tienyik.git
synced 2026-06-18 08:18:59 +08:00
feat: add log & supporting packages
This commit is contained in:
29
api/auth/client.go
Normal file
29
api/auth/client.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/fumiama/tienyik/internal/hcli"
|
||||
"github.com/fumiama/tienyik/internal/hson"
|
||||
"github.com/fumiama/tienyik/internal/textio"
|
||||
)
|
||||
|
||||
type RequestNegotiationEncKey struct {
|
||||
CertData string `json:"certData"`
|
||||
CertType string `json:"certType"`
|
||||
Etype string `json:"etype"`
|
||||
}
|
||||
|
||||
type ResponseNegotiationEncKey struct {
|
||||
EncData string `json:"encData"`
|
||||
EncKey string `json:"encKey"`
|
||||
}
|
||||
|
||||
func NegotiationEncKey(r *RequestNegotiationEncKey) (*ResponseNegotiationEncKey, error) {
|
||||
resp, err := hcli.Post(textio.API(), bytes.NewReader(hson.Marshal(nil, r)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
return hson.Unmarshal[*ResponseNegotiationEncKey](nil, resp.Body)
|
||||
}
|
||||
Reference in New Issue
Block a user