feat: use wire

This commit is contained in:
Yuzuki616
2025-05-07 17:22:29 +09:00
parent 05a1e586ed
commit 9e18c06199
14 changed files with 418 additions and 222 deletions

View File

@@ -22,7 +22,6 @@ type Conf struct {
Log Log `json:"Log,omitempty"`
Watcher Watcher `json:"Watcher,omitempty"`
Plugin Plugins `json:"Plugin,omitempty"` // Only accept from file path
Core []Core `json:"Core,omitempty"`
Acme []ACME `json:"Acme,omitempty"`
Node []Node `json:"Node,omitempty"`
}
@@ -35,7 +34,6 @@ func New(path string) *Conf {
WatchRemoteConfig: true,
},
Log: newLog(),
Core: make([]Core, 0),
Acme: make([]ACME, 0),
Plugin: Plugins{},
Node: make([]Node, 0),

View File

@@ -23,7 +23,7 @@ type Remote struct {
}
type Options struct {
Core string `json:"Core"`
Core string `json:"CorePlugin"`
Panel string `json:"Panel"`
Acme string `json:"Acme"`
Cert Cert `json:"Cert"`

View File

@@ -5,14 +5,14 @@ import (
"github.com/goccy/go-json"
)
type Core struct {
Type string `json:"type"`
type CorePlugin struct {
DataPath string `json:"DataPath,omitempty"`
Config json.RawMessage `json:"Config,omitempty"`
Plugin
}
type _core Core
type _core CorePlugin
func (c *Core) UnmarshalJSON(data []byte) error {
func (c *CorePlugin) UnmarshalJSON(data []byte) error {
err := json.Unmarshal(data, (*_core)(c))
if err != nil {
return fmt.Errorf("failed to unmarshal core: %v", err)
@@ -20,12 +20,17 @@ func (c *Core) UnmarshalJSON(data []byte) error {
if len(c.Config) == 0 {
c.Config = data
}
err = json.Unmarshal(c.Config, &c.Plugin)
if err != nil {
return fmt.Errorf("failed to unmarshal core config: %v", err)
}
return nil
}
type Plugins struct {
Core []Plugin `json:"core"`
Panel []Plugin `json:"panel"`
Core []CorePlugin `json:"core"`
Panel []Plugin `json:"panel"`
}
type Plugin struct {