Refactor RegisterHTTPFunc

This commit is contained in:
ionutboangiu
2021-04-01 17:53:17 +03:00
committed by Dan Christian Bogos
parent 40b93a5b14
commit cb2585837a
4 changed files with 7 additions and 7 deletions

View File

@@ -584,10 +584,10 @@ func main() {
// Rpc/http server
server := cores.NewServer(caps)
if len(cfg.HTTPCfg().RegistrarSURL) != 0 {
server.RegisterHttpFunc(cfg.HTTPCfg().RegistrarSURL, registrarc.Registrar)
server.RegisterHTTPFunc(cfg.HTTPCfg().RegistrarSURL, registrarc.Registrar)
}
if cfg.ConfigSCfg().Enabled {
server.RegisterHttpFunc(cfg.ConfigSCfg().URL, config.HandlerConfigS)
server.RegisterHTTPFunc(cfg.ConfigSCfg().URL, config.HandlerConfigS)
}
if *httpPprofPath != utils.EmptyString {
server.RegisterProfiler(*httpPprofPath)

View File

@@ -61,7 +61,7 @@ func TestNewServer(t *testing.T) {
}
}
func TestRegisterHttpFunc(t *testing.T) {
func TestRegisterHTTPFunc(t *testing.T) {
log.SetOutput(io.Discard)
cfgDflt := config.NewDefaultCGRConfig()
cfgDflt.CoreSCfg().CapsStatsInterval = 1
@@ -83,7 +83,7 @@ func TestRegisterHttpFunc(t *testing.T) {
handler := func(http.ResponseWriter, *http.Request) {}
rcv.RegisterHttpFunc("/home", handler)
rcv.RegisterHTTPFunc("/home", handler)
rcv.RpcRegisterName(utils.EmptyString, handler)

View File

@@ -128,8 +128,8 @@ func (cdrS *CDRServer) ListenAndServe(stopChan chan struct{}) {
// RegisterHandlersToServer is called by cgr-engine to register HTTP URL handlers
func (cdrS *CDRServer) RegisterHandlersToServer(server utils.Server) {
server.RegisterHttpFunc(cdrS.cgrCfg.HTTPCfg().HTTPCDRsURL, cdrS.cgrCdrHandler)
server.RegisterHttpFunc(cdrS.cgrCfg.HTTPCfg().HTTPFreeswitchCDRsURL, cdrS.fsCdrHandler)
server.RegisterHTTPFunc(cdrS.cgrCfg.HTTPCfg().HTTPCDRsURL, cdrS.cgrCdrHandler)
server.RegisterHTTPFunc(cdrS.cgrCfg.HTTPCfg().HTTPFreeswitchCDRsURL, cdrS.fsCdrHandler)
}
// chrgrSProcessEvent forks CGREventWithOpts into multiples based on matching ChargerS profiles

View File

@@ -31,7 +31,7 @@ import (
type Server interface {
RpcRegister(rcvr interface{})
RpcRegisterName(name string, rcvr interface{})
RegisterHttpFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
RegisterHTTPFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
RegisterHttpHandler(pattern string, handler http.Handler)
BiRPCRegisterName(method string, handlerFunc interface{})
}