2023-03-16 18:56:36 +00:00
|
|
|
package configapi
|
2023-03-10 20:59:56 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"encoding/json"
|
2023-03-25 20:15:00 +00:00
|
|
|
"github.com/azukaar/cosmos-server/src/utils"
|
2023-03-10 20:59:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func ConfigApiGet(w http.ResponseWriter, req *http.Request) {
|
2023-03-16 18:56:36 +00:00
|
|
|
if utils.AdminOnly(w, req) != nil {
|
2023-03-10 20:59:56 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(req.Method == "GET") {
|
|
|
|
config := utils.GetBaseMainConfig()
|
|
|
|
|
|
|
|
// delete AuthPrivateKey and TLSKey
|
2023-03-16 18:56:36 +00:00
|
|
|
config.HTTPConfig.AuthPrivateKey = ""
|
|
|
|
config.HTTPConfig.TLSKey = ""
|
2023-03-10 20:59:56 +00:00
|
|
|
|
|
|
|
json.NewEncoder(w).Encode(map[string]interface{}{
|
|
|
|
"status": "OK",
|
|
|
|
"data": config,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
utils.Error("SettingGet: Method not allowed" + req.Method, nil)
|
|
|
|
utils.HTTPError(w, "Method not allowed", http.StatusMethodNotAllowed, "HTTP001")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|