expose PATCH /config

This commit is contained in:
bel
2023-03-26 14:17:33 -06:00
parent af42db6803
commit c663b1a12c
4 changed files with 112 additions and 12 deletions

View File

@@ -6,27 +6,32 @@ import (
patch "github.com/evanphx/json-patch/v5"
)
type config struct {
Feedback struct {
type (
config struct {
Feedback configFeedback
Users map[string]configUser
Players []configPlayer
Quiet bool
}
configFeedback struct {
Addr string
TTSURL string
}
Users map[string]struct {
configUser struct {
Player int
Message string
}
Players []struct {
configPlayer struct {
Transformation transformation
}
Quiet bool
}
)
func (cfg config) WithJSONPatch(v interface{}) config {
func (cfg config) WithPatch(v interface{}) config {
originalData, _ := json.Marshal(cfg)
patchData, err := json.Marshal(v)
if err != nil {
return cfg
}
patchData, _ := json.Marshal(v)
patcher, err := patch.DecodePatch(patchData)
if err != nil {
return cfg