mirror of
https://github.com/InazumaV/Ratte.git
synced 2026-02-04 04:30:09 +00:00
feat: use wire
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user