From 9458fd31dc25ed499fda2270a355f032fd90a34b Mon Sep 17 00:00:00 2001 From: yangwensi Date: Wed, 11 Dec 2019 19:26:24 +0800 Subject: [PATCH] Update code style in bfe_modules (#171) --- bfe_modules/mod_auth_basic/mod_auth_basic.go | 4 ++-- bfe_modules/mod_block/mod_block.go | 4 ++-- bfe_modules/mod_compress/mod_compress.go | 4 ++-- bfe_modules/mod_errors/mod_errors.go | 2 +- bfe_modules/mod_geo/mod_geo.go | 4 ++-- bfe_modules/mod_header/mod_header.go | 2 +- bfe_modules/mod_http_code/mod_http_code.go | 2 +- bfe_modules/mod_logid/mod_logid.go | 2 +- bfe_modules/mod_redirect/mod_redirect.go | 2 +- bfe_modules/mod_rewrite/mod_rewrite.go | 2 +- bfe_modules/mod_static/mod_static.go | 4 ++-- bfe_modules/mod_trust_clientip/mod_trust_clientip.go | 4 ++-- bfe_server/web_server.go | 4 ++-- go.mod | 9 ++++----- 14 files changed, 24 insertions(+), 25 deletions(-) diff --git a/bfe_modules/mod_auth_basic/mod_auth_basic.go b/bfe_modules/mod_auth_basic/mod_auth_basic.go index 3d312ca3c..6f342f3c0 100644 --- a/bfe_modules/mod_auth_basic/mod_auth_basic.go +++ b/bfe_modules/mod_auth_basic/mod_auth_basic.go @@ -179,12 +179,12 @@ func (m *ModuleAuthBasic) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.We return fmt.Errorf("%s.Init(): AddFilter(m.authBasicHandler): %v", m.name, err) } - err = web_monitor.RegisterHandlers(whs, web_monitor.WEB_HANDLE_MONITOR, m.monitorHandlers()) + err = web_monitor.RegisterHandlers(whs, web_monitor.WebHandleMonitor, m.monitorHandlers()) if err != nil { return fmt.Errorf("%s.Init():RegisterHandlers(m.monitorHandlers): %v", m.name, err) } - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_RELOAD, m.name, m.loadConfData) + err = whs.RegisterHandler(web_monitor.WebHandleReload, m.name, m.loadConfData) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.loadConfData): %v", m.name, err) } diff --git a/bfe_modules/mod_block/mod_block.go b/bfe_modules/mod_block/mod_block.go index b7bd26f89..bf270934c 100644 --- a/bfe_modules/mod_block/mod_block.go +++ b/bfe_modules/mod_block/mod_block.go @@ -271,12 +271,12 @@ func (m *ModuleBlock) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHan } // register web handler for monitor - err = web_monitor.RegisterHandlers(whs, web_monitor.WEB_HANDLE_MONITOR, m.monitorHandlers()) + err = web_monitor.RegisterHandlers(whs, web_monitor.WebHandleMonitor, m.monitorHandlers()) if err != nil { return fmt.Errorf("%s.Init():RegisterHandlers(m.monitorHandlers): %s", m.name, err.Error()) } // register web handler for reload - err = web_monitor.RegisterHandlers(whs, web_monitor.WEB_HANDLE_RELOAD, m.reloadHandlers()) + err = web_monitor.RegisterHandlers(whs, web_monitor.WebHandleReload, m.reloadHandlers()) if err != nil { return fmt.Errorf("%s.Init():RegisterHandlers(m.reloadHandlers): %s", m.name, err.Error()) } diff --git a/bfe_modules/mod_compress/mod_compress.go b/bfe_modules/mod_compress/mod_compress.go index b8fe92ab3..9681e60a9 100644 --- a/bfe_modules/mod_compress/mod_compress.go +++ b/bfe_modules/mod_compress/mod_compress.go @@ -211,12 +211,12 @@ func (m *ModuleCompress) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.Web return fmt.Errorf("%s.Init(): AddFilter(m.compressHandler): %v", m.name, err) } - err = web_monitor.RegisterHandlers(whs, web_monitor.WEB_HANDLE_MONITOR, m.monitorHandlers()) + err = web_monitor.RegisterHandlers(whs, web_monitor.WebHandleMonitor, m.monitorHandlers()) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandlers(m.monitorHandlers): %v", m.name, err) } - err = web_monitor.RegisterHandlers(whs, web_monitor.WEB_HANDLE_RELOAD, m.reloadHandlers()) + err = web_monitor.RegisterHandlers(whs, web_monitor.WebHandleReload, m.reloadHandlers()) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandlers(m.reloadHandlerr): %v", m.name, err) } diff --git a/bfe_modules/mod_errors/mod_errors.go b/bfe_modules/mod_errors/mod_errors.go index 9916cabac..0cee62950 100644 --- a/bfe_modules/mod_errors/mod_errors.go +++ b/bfe_modules/mod_errors/mod_errors.go @@ -122,7 +122,7 @@ func (m *ModuleErrors) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHa } // register web handler for reload - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_RELOAD, m.name, m.loadConfData) + err = whs.RegisterHandler(web_monitor.WebHandleReload, m.name, m.loadConfData) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.loadConfData): %s", m.name, err.Error()) } diff --git a/bfe_modules/mod_geo/mod_geo.go b/bfe_modules/mod_geo/mod_geo.go index ebc4ab50e..6fc290612 100644 --- a/bfe_modules/mod_geo/mod_geo.go +++ b/bfe_modules/mod_geo/mod_geo.go @@ -200,12 +200,12 @@ func (m *ModuleGeo) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHandl } // register web handler for reload - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_RELOAD, m.name, m.loadConfData) + err = whs.RegisterHandler(web_monitor.WebHandleReload, m.name, m.loadConfData) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.loadConfData): %s", m.name, err.Error()) } // register web handler for monitor - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_MONITOR, m.name, m.getState) + err = whs.RegisterHandler(web_monitor.WebHandleMonitor, m.name, m.getState) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.getState): %s", m.name, err.Error()) } diff --git a/bfe_modules/mod_header/mod_header.go b/bfe_modules/mod_header/mod_header.go index 1325c9fab..4094130da 100644 --- a/bfe_modules/mod_header/mod_header.go +++ b/bfe_modules/mod_header/mod_header.go @@ -196,7 +196,7 @@ func (m *ModuleHeader) init(cfg *ConfModHeader, cbs *bfe_module.BfeCallbacks, } // register web handler for reload - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_RELOAD, m.name, m.loadConfData) + err = whs.RegisterHandler(web_monitor.WebHandleReload, m.name, m.loadConfData) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.loadConfData): %s", m.name, err.Error()) } diff --git a/bfe_modules/mod_http_code/mod_http_code.go b/bfe_modules/mod_http_code/mod_http_code.go index fce654ccb..cee5d98b4 100644 --- a/bfe_modules/mod_http_code/mod_http_code.go +++ b/bfe_modules/mod_http_code/mod_http_code.go @@ -93,7 +93,7 @@ func (m *ModuleHttpCode) Init(cbs *bfe_module.BfeCallbacks, } // register web handlers for monitor - err = web_monitor.RegisterHandlers(whs, web_monitor.WEB_HANDLE_MONITOR, m.monitorHandlers()) + err = web_monitor.RegisterHandlers(whs, web_monitor.WebHandleMonitor, m.monitorHandlers()) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandlers(m.monitorHandlers): %v", m.name, err) } diff --git a/bfe_modules/mod_logid/mod_logid.go b/bfe_modules/mod_logid/mod_logid.go index 931d50e85..da862aae4 100644 --- a/bfe_modules/mod_logid/mod_logid.go +++ b/bfe_modules/mod_logid/mod_logid.go @@ -78,7 +78,7 @@ func (m *ModuleLogId) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHan } // register web handler - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_MONITOR, m.name, m.getState) + err = whs.RegisterHandler(web_monitor.WebHandleMonitor, m.name, m.getState) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.getState): %s", m.name, err.Error()) } diff --git a/bfe_modules/mod_redirect/mod_redirect.go b/bfe_modules/mod_redirect/mod_redirect.go index 7ba8eaf24..1d01ce0b7 100644 --- a/bfe_modules/mod_redirect/mod_redirect.go +++ b/bfe_modules/mod_redirect/mod_redirect.go @@ -157,7 +157,7 @@ func (m *ModuleRedirect) init(cfg *ConfModRedirect, cbs *bfe_module.BfeCallbacks } // register web handler for reload - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_RELOAD, m.name, m.loadConfData) + err = whs.RegisterHandler(web_monitor.WebHandleReload, m.name, m.loadConfData) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.loadConfData): %s", m.name, err.Error()) } diff --git a/bfe_modules/mod_rewrite/mod_rewrite.go b/bfe_modules/mod_rewrite/mod_rewrite.go index 5d1f3c640..5ac8a011e 100644 --- a/bfe_modules/mod_rewrite/mod_rewrite.go +++ b/bfe_modules/mod_rewrite/mod_rewrite.go @@ -147,7 +147,7 @@ func (m *ModuleReWrite) init(cfg *ConfModReWrite, cbs *bfe_module.BfeCallbacks, } // register web handler for reload - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_RELOAD, m.name, m.loadConfData) + err = whs.RegisterHandler(web_monitor.WebHandleReload, m.name, m.loadConfData) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.loadConfData): %s", m.name, err.Error()) } diff --git a/bfe_modules/mod_static/mod_static.go b/bfe_modules/mod_static/mod_static.go index 2015a90ea..1818659df 100644 --- a/bfe_modules/mod_static/mod_static.go +++ b/bfe_modules/mod_static/mod_static.go @@ -271,12 +271,12 @@ func (m *ModuleStatic) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHa return fmt.Errorf("%s.Init(): AddFilter(m.staticFileHandler): %v", m.name, err) } - err = web_monitor.RegisterHandlers(whs, web_monitor.WEB_HANDLE_MONITOR, m.monitorHandlers()) + err = web_monitor.RegisterHandlers(whs, web_monitor.WebHandleMonitor, m.monitorHandlers()) if err != nil { return fmt.Errorf("%s.Init():RegisterHandlers(m.monitorHandlers): %s", m.name, err.Error()) } - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_RELOAD, m.name, m.loadConfData) + err = whs.RegisterHandler(web_monitor.WebHandleReload, m.name, m.loadConfData) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.loadConfData): %v", m.name, err) } diff --git a/bfe_modules/mod_trust_clientip/mod_trust_clientip.go b/bfe_modules/mod_trust_clientip/mod_trust_clientip.go index 831e27670..0d4a38576 100644 --- a/bfe_modules/mod_trust_clientip/mod_trust_clientip.go +++ b/bfe_modules/mod_trust_clientip/mod_trust_clientip.go @@ -224,13 +224,13 @@ func (m *ModuleTrustClientIP) init(cfg *ConfModTrustClientIP, cbs *bfe_module.Bf } // register web handler for monitor - err = web_monitor.RegisterHandlers(whs, web_monitor.WEB_HANDLE_MONITOR, m.monitorHandlers()) + err = web_monitor.RegisterHandlers(whs, web_monitor.WebHandleMonitor, m.monitorHandlers()) if err != nil { return fmt.Errorf("%s.Init():RegisterHandlers(m.monitorHandlers): %s", m.name, err.Error()) } // register web handler for reload - err = whs.RegisterHandler(web_monitor.WEB_HANDLE_RELOAD, m.name, m.loadConfData) + err = whs.RegisterHandler(web_monitor.WebHandleReload, m.name, m.loadConfData) if err != nil { return fmt.Errorf("%s.Init(): RegisterHandler(m.loadConfData): %s", m.name, err.Error()) } diff --git a/bfe_server/web_server.go b/bfe_server/web_server.go index 7f48759c2..735bc5eb9 100644 --- a/bfe_server/web_server.go +++ b/bfe_server/web_server.go @@ -132,14 +132,14 @@ func (m *BfeMonitor) reloadHandlers() map[string]interface{} { func (m *BfeMonitor) WebHandlersInit(srv *BfeServer) error { // register handlers for monitor - err := web_monitor.RegisterHandlers(m.WebHandlers, web_monitor.WEB_HANDLE_MONITOR, + err := web_monitor.RegisterHandlers(m.WebHandlers, web_monitor.WebHandleMonitor, m.monitorHandlers()) if err != nil { return err } // register handlers for for reload - err = web_monitor.RegisterHandlers(m.WebHandlers, web_monitor.WEB_HANDLE_RELOAD, + err = web_monitor.RegisterHandlers(m.WebHandlers, web_monitor.WebHandleReload, m.reloadHandlers()) if err != nil { return err diff --git a/go.mod b/go.mod index aec7ab0a8..05f32d0cd 100644 --- a/go.mod +++ b/go.mod @@ -5,17 +5,16 @@ go 1.12 require ( github.com/abbot/go-http-auth v0.4.1-0.20181019201920-860ed7f246ff github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 // indirect - github.com/baidu/go-lib v0.0.0-20191203131845-1dc193267345 + github.com/baidu/go-lib v0.0.0-20191211084149-f80a8a568e3f github.com/gomodule/redigo v2.0.0+incompatible github.com/oschwald/geoip2-golang v1.3.0 github.com/oschwald/maxminddb-golang v1.5.0 // indirect github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 github.com/spaolacci/murmur3 v1.1.0 github.com/zmap/go-iptree v0.0.0-20170831022036-1948b1097e25 - golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 - golang.org/x/net v0.0.0-20190620200207-3b0461eec859 - golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed - golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd // indirect + golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 + golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 + golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 gopkg.in/gcfg.v1 v1.2.3 gopkg.in/warnings.v0 v0.1.2 // indirect )