mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-19 23:11:25 +02:00
fix(lint): improve styling and fix lint errors
This commit is contained in:
@@ -26,11 +26,9 @@ var (
|
||||
|
||||
const configEventFlushInterval = 500 * time.Millisecond
|
||||
|
||||
const (
|
||||
cfgRenameWarn = `Config file renamed, not reloading.
|
||||
Make sure you rename it back before next time you start.`
|
||||
cfgDeleteWarn = `Config file deleted, not reloading.
|
||||
You may run "ls-config" to show or dump the current config.`
|
||||
var (
|
||||
errCfgRenameWarn = errors.New("config file renamed, not reloading; Make sure you rename it back before next time you start")
|
||||
errCfgDeleteWarn = errors.New(`config file deleted, not reloading; You may run "ls-config" to show or dump the current config`)
|
||||
)
|
||||
|
||||
func logNotifyError(action string, err error) {
|
||||
@@ -142,11 +140,11 @@ func OnConfigChange(ev []watcherEvents.Event) {
|
||||
// no matter how many events during the interval
|
||||
// just reload once and check the last event
|
||||
switch ev[len(ev)-1].Action {
|
||||
case events.ActionFileRenamed:
|
||||
logNotifyWarn("rename", errors.New(cfgRenameWarn))
|
||||
case watcherEvents.ActionFileRenamed:
|
||||
logNotifyWarn("rename", errCfgRenameWarn)
|
||||
return
|
||||
case events.ActionFileDeleted:
|
||||
logNotifyWarn("delete", errors.New(cfgDeleteWarn))
|
||||
case watcherEvents.ActionFileDeleted:
|
||||
logNotifyWarn("delete", errCfgDeleteWarn)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/goccy/go-yaml"
|
||||
"github.com/puzpuzpuz/xsync/v4"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
acl "github.com/yusing/godoxy/internal/acl/types"
|
||||
"github.com/yusing/godoxy/internal/agentpool"
|
||||
"github.com/yusing/godoxy/internal/api"
|
||||
@@ -90,11 +91,6 @@ func SetState(state config.State) {
|
||||
cfg := state.Value()
|
||||
config.ActiveState.Store(state)
|
||||
homepage.ActiveConfig.Store(&cfg.Homepage)
|
||||
if autocertProvider := state.AutoCertProvider(); autocertProvider != nil {
|
||||
autocert.ActiveProvider.Store(autocertProvider.(*autocert.Provider))
|
||||
} else {
|
||||
autocert.ActiveProvider.Store(nil)
|
||||
}
|
||||
}
|
||||
|
||||
func HasState() bool {
|
||||
@@ -203,25 +199,31 @@ func (state *state) NumProviders() int {
|
||||
}
|
||||
|
||||
func (state *state) FlushTmpLog() {
|
||||
state.tmpLogBuf.WriteTo(os.Stdout)
|
||||
_, _ = state.tmpLogBuf.WriteTo(os.Stdout)
|
||||
state.tmpLogBuf.Reset()
|
||||
}
|
||||
|
||||
func (state *state) StartAPIServers() {
|
||||
// API Handler needs to start after auth is initialized.
|
||||
server.StartServer(state.task.Subtask("api_server", false), server.Options{
|
||||
_, err := server.StartServer(state.task.Subtask("api_server", false), server.Options{
|
||||
Name: "api",
|
||||
HTTPAddr: common.APIHTTPAddr,
|
||||
Handler: api.NewHandler(true),
|
||||
})
|
||||
if err != nil {
|
||||
log.Err(err).Msg("failed to start API server")
|
||||
}
|
||||
|
||||
// Local API Handler is used for unauthenticated access.
|
||||
if common.LocalAPIHTTPAddr != "" {
|
||||
server.StartServer(state.task.Subtask("local_api_server", false), server.Options{
|
||||
_, err := server.StartServer(state.task.Subtask("local_api_server", false), server.Options{
|
||||
Name: "local_api",
|
||||
HTTPAddr: common.LocalAPIHTTPAddr,
|
||||
Handler: api.NewHandler(false),
|
||||
})
|
||||
if err != nil {
|
||||
log.Err(err).Msg("failed to start local API server")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user