mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-01-20 17:30:40 +07:00
Marshal /update response too
This commit is contained in:
parent
43de7ba39c
commit
d2bc627429
14
api.go
14
api.go
@ -71,6 +71,12 @@ func webRegisterPost(w http.ResponseWriter, r *http.Request, _ httprouter.Params
|
||||
w.Write(reg)
|
||||
}
|
||||
|
||||
// UpdateResponse is a struct for update response JSON
|
||||
type UpdateResponse struct {
|
||||
TextValue string `json:"txt"`
|
||||
Fulldomain string `json:"fulldomain"`
|
||||
}
|
||||
|
||||
func webUpdatePost(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
var updStatus int
|
||||
var upd []byte
|
||||
@ -99,7 +105,13 @@ func webUpdatePost(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
|
||||
} else {
|
||||
log.WithFields(log.Fields{"subdomain": a.Subdomain, "txt": a.Value}).Debug("TXT updated")
|
||||
updStatus = http.StatusOK
|
||||
upd = []byte("{\"txt\": \"" + a.Value + "\", \"fulldomain\": \"" + a.Subdomain + "." + Config.General.Domain + "\"}")
|
||||
updStruct := UpdateResponse{a.Value, a.Subdomain + "." + Config.General.Domain}
|
||||
upd, err = json.Marshal(updStruct)
|
||||
if err != nil {
|
||||
updStatus = http.StatusInternalServerError
|
||||
upd = jsonError("json_error")
|
||||
log.WithFields(log.Fields{"error": "json"}).Debug("Could not marshal JSON")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
Loading…
Reference in New Issue
Block a user