mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-01 01:22:34 +02:00
fix(imports): due to previous refactor
This commit is contained in:
parent
df193a42fc
commit
5a3e3f19c7
9 changed files with 22 additions and 22 deletions
|
@ -22,8 +22,8 @@ import (
|
||||||
"github.com/yusing/go-proxy/internal/notif"
|
"github.com/yusing/go-proxy/internal/notif"
|
||||||
"github.com/yusing/go-proxy/internal/proxmox"
|
"github.com/yusing/go-proxy/internal/proxmox"
|
||||||
proxy "github.com/yusing/go-proxy/internal/route/provider"
|
proxy "github.com/yusing/go-proxy/internal/route/provider"
|
||||||
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
|
||||||
F "github.com/yusing/go-proxy/internal/utils/functional"
|
F "github.com/yusing/go-proxy/internal/utils/functional"
|
||||||
"github.com/yusing/go-proxy/internal/utils/strutils/ansi"
|
"github.com/yusing/go-proxy/internal/utils/strutils/ansi"
|
||||||
"github.com/yusing/go-proxy/internal/watcher"
|
"github.com/yusing/go-proxy/internal/watcher"
|
||||||
|
@ -223,7 +223,7 @@ func (cfg *Config) load() gperr.Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
model := config.DefaultConfig()
|
model := config.DefaultConfig()
|
||||||
if err := utils.UnmarshalValidateYAML(data, model); err != nil {
|
if err := serialization.UnmarshalValidateYAML(data, model); err != nil {
|
||||||
gperr.LogFatal(errMsg, err)
|
gperr.LogFatal(errMsg, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/yusing/go-proxy/internal/homepage/widgets"
|
"github.com/yusing/go-proxy/internal/homepage/widgets"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -32,7 +32,7 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
utils.RegisterDefaultValueFactory(func() *ItemConfig {
|
serialization.RegisterDefaultValueFactory(func() *ItemConfig {
|
||||||
return &ItemConfig{
|
return &ItemConfig{
|
||||||
Show: true,
|
Show: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
"github.com/lithammer/fuzzysearch/fuzzy"
|
"github.com/lithammer/fuzzysearch/fuzzy"
|
||||||
"github.com/yusing/go-proxy/internal/common"
|
"github.com/yusing/go-proxy/internal/common"
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
|
||||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ func InitIconListCache() {
|
||||||
iconsCache.Lock()
|
iconsCache.Lock()
|
||||||
defer iconsCache.Unlock()
|
defer iconsCache.Unlock()
|
||||||
|
|
||||||
err := utils.LoadJSONIfExist(common.IconListCachePath, iconsCache)
|
err := serialization.LoadJSONIfExist(common.IconListCachePath, iconsCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.Error().Err(err).Msg("failed to load icons")
|
logging.Error().Err(err).Msg("failed to load icons")
|
||||||
} else if len(iconsCache.Icons) > 0 {
|
} else if len(iconsCache.Icons) > 0 {
|
||||||
|
@ -113,7 +113,7 @@ func InitIconListCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
task.OnProgramExit("save_icons_cache", func() {
|
task.OnProgramExit("save_icons_cache", func() {
|
||||||
utils.SaveJSON(common.IconListCachePath, iconsCache, 0o644)
|
serialization.SaveJSON(common.IconListCachePath, iconsCache, 0o644)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ func ListAvailableIcons() (*Cache, error) {
|
||||||
|
|
||||||
iconsCache.LastUpdate = time.Now()
|
iconsCache.LastUpdate = time.Now()
|
||||||
|
|
||||||
err := utils.SaveJSON(common.IconListCachePath, iconsCache, 0o644)
|
err := serialization.SaveJSON(common.IconListCachePath, iconsCache, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.Warn().Err(err).Msg("failed to save icons")
|
logging.Warn().Err(err).Msg("failed to save icons")
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -42,7 +42,7 @@ func (cfg *Config) UnmarshalMap(m map[string]any) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return gperr.New("invalid config")
|
return gperr.New("invalid config")
|
||||||
}
|
}
|
||||||
if err := utils.MapUnmarshalValidate(m, &cfg.Config); err != nil {
|
if err := serialization.MapUnmarshalValidate(m, &cfg.Config); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
"github.com/yusing/go-proxy/internal/common"
|
"github.com/yusing/go-proxy/internal/common"
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type namespace string
|
type namespace string
|
||||||
|
@ -77,7 +77,7 @@ func loadNS[T store](ns namespace) T {
|
||||||
func save() error {
|
func save() error {
|
||||||
errs := gperr.NewBuilder("failed to save data stores")
|
errs := gperr.NewBuilder("failed to save data stores")
|
||||||
for ns, store := range stores {
|
for ns, store := range stores {
|
||||||
if err := utils.SaveJSON(filepath.Join(storesPath, string(ns)+".json"), &store, 0o644); err != nil {
|
if err := serialization.SaveJSON(filepath.Join(storesPath, string(ns)+".json"), &store, 0o644); err != nil {
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
gphttp "github.com/yusing/go-proxy/internal/net/gphttp"
|
gphttp "github.com/yusing/go-proxy/internal/net/gphttp"
|
||||||
"github.com/yusing/go-proxy/internal/net/types"
|
"github.com/yusing/go-proxy/internal/net/types"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
F "github.com/yusing/go-proxy/internal/utils/functional"
|
F "github.com/yusing/go-proxy/internal/utils/functional"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
utils.MustRegisterValidation("status_code", func(fl validator.FieldLevel) bool {
|
serialization.MustRegisterValidation("status_code", func(fl validator.FieldLevel) bool {
|
||||||
statusCode := fl.Field().Int()
|
statusCode := fl.Field().Int()
|
||||||
return gphttp.IsStatusCodeValid(int(statusCode))
|
return gphttp.IsStatusCodeValid(int(statusCode))
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
gphttp "github.com/yusing/go-proxy/internal/net/gphttp"
|
gphttp "github.com/yusing/go-proxy/internal/net/gphttp"
|
||||||
"github.com/yusing/go-proxy/internal/net/gphttp/reverseproxy"
|
"github.com/yusing/go-proxy/internal/net/gphttp/reverseproxy"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -118,14 +118,14 @@ func (m *Middleware) apply(optsRaw OptionsRaw) gperr.Error {
|
||||||
"priority": optsRaw["priority"],
|
"priority": optsRaw["priority"],
|
||||||
"bypass": optsRaw["bypass"],
|
"bypass": optsRaw["bypass"],
|
||||||
}
|
}
|
||||||
if err := utils.MapUnmarshalValidate(commonOpts, &m.commonOptions); err != nil {
|
if err := serialization.MapUnmarshalValidate(commonOpts, &m.commonOptions); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
optsRaw = maps.Clone(optsRaw)
|
optsRaw = maps.Clone(optsRaw)
|
||||||
for k := range commonOpts {
|
for k := range commonOpts {
|
||||||
delete(optsRaw, k)
|
delete(optsRaw, k)
|
||||||
}
|
}
|
||||||
return utils.MapUnmarshalValidate(optsRaw, m.impl)
|
return serialization.MapUnmarshalValidate(optsRaw, m.impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Middleware) finalize() error {
|
func (m *Middleware) finalize() error {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
"github.com/yusing/go-proxy/internal/route"
|
"github.com/yusing/go-proxy/internal/route"
|
||||||
U "github.com/yusing/go-proxy/internal/utils"
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||||
"github.com/yusing/go-proxy/internal/watcher"
|
"github.com/yusing/go-proxy/internal/watcher"
|
||||||
)
|
)
|
||||||
|
@ -180,7 +180,7 @@ func (p *DockerProvider) routesFromContainerLabels(container *docker.Container)
|
||||||
}
|
}
|
||||||
|
|
||||||
// deserialize map into entry object
|
// deserialize map into entry object
|
||||||
err := U.MapUnmarshalValidate(entryMap, r)
|
err := serialization.MapUnmarshalValidate(entryMap, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(err.Subject(alias))
|
errs.Add(err.Subject(alias))
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,7 +189,7 @@ func (p *DockerProvider) routesFromContainerLabels(container *docker.Container)
|
||||||
}
|
}
|
||||||
if wildcardProps != nil {
|
if wildcardProps != nil {
|
||||||
for _, re := range routes {
|
for _, re := range routes {
|
||||||
if err := U.MapUnmarshalValidate(wildcardProps, re); err != nil {
|
if err := serialization.MapUnmarshalValidate(wildcardProps, re); err != nil {
|
||||||
errs.Add(err.Subject(docker.WildcardAlias))
|
errs.Add(err.Subject(docker.WildcardAlias))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
"github.com/yusing/go-proxy/internal/route"
|
"github.com/yusing/go-proxy/internal/route"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
"github.com/yusing/go-proxy/internal/serialization"
|
||||||
W "github.com/yusing/go-proxy/internal/watcher"
|
W "github.com/yusing/go-proxy/internal/watcher"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ func FileProviderImpl(filename string) (ProviderImpl, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func validate(data []byte) (routes route.Routes, err gperr.Error) {
|
func validate(data []byte) (routes route.Routes, err gperr.Error) {
|
||||||
err = utils.UnmarshalValidateYAML(data, &routes)
|
err = serialization.UnmarshalValidateYAML(data, &routes)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue