adds request log to txt/json endpoints removes un-necessary debug log

This commit is contained in:
Hyatt 2024-01-25 07:08:36 -06:00
parent 4e03fcda83
commit 33cb4defd2
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA
3 changed files with 7 additions and 2 deletions

View File

@ -52,8 +52,6 @@ func (c NsUpdateStruct) UpdateTXT(record, recordType, value string) error {
}
oldTXT := strings.TrimLeft(strings.TrimRight(stdout.String(), "\n\""), "\"")
config.Cfg.Log.Debug("existing record", "record", strings.ReplaceAll(oldTXT, `" "`, ``))
config.Cfg.Log.Debug("new record", "record", strings.ReplaceAll(value, `" "`, ``))
if strings.ReplaceAll(oldTXT, `" "`, ``) != strings.ReplaceAll(value, `" "`, ``) {
config.Cfg.Log.Debug("deleting record", "record", record)

View File

@ -125,6 +125,9 @@ func webRoot(w http.ResponseWriter, r *http.Request) {
}
func webJSON(w http.ResponseWriter, r *http.Request) {
httpAccessLog(r)
crossSiteOrigin(w)
if strings.ToLower(r.Method) != "get" {
config.Cfg.Log.Debug("http invalid method", "url", r.URL.Path, "expected", "GET", "received", r.Method)
tmpltError(w, http.StatusBadRequest, "Invalid http method.")
@ -155,6 +158,9 @@ func webJSON(w http.ResponseWriter, r *http.Request) {
}
func webTXT(w http.ResponseWriter, r *http.Request) {
httpAccessLog(r)
crossSiteOrigin(w)
if strings.ToLower(r.Method) != "get" {
config.Cfg.Log.Debug("http invalid method", "url", r.URL.Path, "expected", "GET", "received", r.Method)
tmpltError(w, http.StatusBadRequest, "Invalid http method.")

View File

@ -147,5 +147,6 @@ func tmpltTXT(w http.ResponseWriter) {
return
}
w.Header().Add("Content-Type", TYPE_TEXT_PLAIN)
w.Write(msgBuffer.Bytes()) //nolint:errcheck
}