mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Update the /configs/ endpoint for http server
This commit is contained in:
committed by
Dan Christian Bogos
parent
b97c442ced
commit
b18bbd6e8c
@@ -1624,8 +1624,9 @@ func (cfg *CGRConfig) AsMapInterface(separator string) map[string]interface{} {
|
||||
func HandlerConfigS(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
// check if the path exists
|
||||
fi, err := os.Stat(r.URL.Path)
|
||||
// take out the /configs prefix and use the rest of url as path
|
||||
path := strings.TrimPrefix(r.URL.Path, "/configs")
|
||||
fi, err := os.Stat(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
w.WriteHeader(404)
|
||||
@@ -1637,9 +1638,9 @@ func HandlerConfigS(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
switch mode := fi.Mode(); {
|
||||
case mode.IsDir():
|
||||
handleConfigSFolder(r.URL.Path, w)
|
||||
handleConfigSFolder(path, w)
|
||||
case mode.IsRegular():
|
||||
handleConfigSFile(r.URL.Path, w)
|
||||
handleConfigSFile(path, w)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ const CGRATES_CFG_JSON = `
|
||||
"http_cdrs": "/cdr_http", // CDRS relative URL ("" to disable)
|
||||
"use_basic_auth": false, // use basic authentication
|
||||
"auth_users": {}, // basic authentication usernames and base64-encoded passwords (eg: { "username1": "cGFzc3dvcmQ=", "username2": "cGFzc3dvcmQy "})
|
||||
"configs": "/configs" // configs
|
||||
"configs": "/configs/" // configs
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -1557,7 +1557,7 @@ func TestDfHttpJsonCfg(t *testing.T) {
|
||||
Http_Cdrs: utils.StringPointer("/cdr_http"),
|
||||
Use_basic_auth: utils.BoolPointer(false),
|
||||
Auth_users: utils.MapStringStringPointer(map[string]string{}),
|
||||
Configs: utils.StringPointer("/configs"),
|
||||
Configs: utils.StringPointer("/configs/"),
|
||||
}
|
||||
if cfg, err := dfCgrJSONCfg.HttpJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -68,12 +68,16 @@ func TestSureTaxCfgloadFromJsonCfg(t *testing.T) {
|
||||
"tax_exemption_code_list": "",
|
||||
},
|
||||
}`
|
||||
tLocal, err := time.LoadLocation("Local")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
expected = SureTaxCfg{
|
||||
Url: utils.EmptyString,
|
||||
ClientNumber: utils.EmptyString,
|
||||
ValidationKey: utils.EmptyString,
|
||||
BusinessUnit: utils.EmptyString,
|
||||
Timezone: &time.Location{},
|
||||
Timezone: tLocal,
|
||||
IncludeLocalCost: false,
|
||||
ReturnFileCode: "0",
|
||||
ResponseGroup: "03",
|
||||
|
||||
Reference in New Issue
Block a user