feat: 支持自定义请求 Header

This commit is contained in:
Mmx233
2023-12-03 20:38:27 +08:00
parent 59bf13467b
commit 6badcf8d08
2 changed files with 9 additions and 5 deletions

View File

@@ -34,4 +34,5 @@ type SettingsConf struct {
Guardian GuardianConf `json:"guardian" yaml:"guardian"`
Log LogConf `json:"log" yaml:"log"`
DDNS DdnsConf `json:"ddns" yaml:"ddns"`
CustomHeader map[string]interface{} `json:"custom_header" yaml:"custom_header"`
}

View File

@@ -1,6 +1,7 @@
package config
import (
"bytes"
"encoding/json"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
@@ -31,7 +32,9 @@ func (Json) Marshal(v any) ([]byte, error) {
return json.MarshalIndent(v, "", " ")
}
func (Json) Unmarshal(data []byte, v any) error {
return json.Unmarshal(data, v)
jsonDecoder := json.NewDecoder(bytes.NewReader(data))
jsonDecoder.UseNumber()
return jsonDecoder.Decode(v)
}
type Yaml struct {