From 6badcf8d08685be2207b4f4722ddc5f41dd75497 Mon Sep 17 00:00:00 2001 From: Mmx233 Date: Sun, 3 Dec 2023 20:38:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=AF=B7=E6=B1=82=20Header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/config/models.go | 9 +++++---- internal/config/reader.go | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/config/models.go b/internal/config/models.go index ebb2b95..55355cb 100644 --- a/internal/config/models.go +++ b/internal/config/models.go @@ -30,8 +30,9 @@ type ( ) type SettingsConf struct { - Basic BasicConf `json:"basic" yaml:"basic"` - Guardian GuardianConf `json:"guardian" yaml:"guardian"` - Log LogConf `json:"log" yaml:"log"` - DDNS DdnsConf `json:"ddns" yaml:"ddns"` + Basic BasicConf `json:"basic" yaml:"basic"` + 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"` } diff --git a/internal/config/reader.go b/internal/config/reader.go index f378b5e..577c5ba 100644 --- a/internal/config/reader.go +++ b/internal/config/reader.go @@ -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 {