fix /delete

This commit is contained in:
echpochmak31 2024-01-14 20:54:54 +03:00
parent b0d9c95f9d
commit aa64be3c24

View file

@ -124,15 +124,17 @@ func main() {
// can access only with valid token (when logged in), deletes client // can access only with valid token (when logged in), deletes client
http.HandleFunc("/delete", logic.ValidateToken(func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/delete", logic.ValidateToken(func(w http.ResponseWriter, r *http.Request) {
id := r.Header.Get("client_id") id := r.Header.Get("client_id")
errorMessage := "Fault during deleting client"
err := blockchainStorage.Delete(id) err := blockchainStorage.Delete(id)
if err != nil { if err != nil {
msg := "Fault during deleting client with id: " + id slog.Error(errorMessage+" (caused by blockchain) with id: "+id, err)
slog.Error(msg, err)
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(msg)) w.Write([]byte(errorMessage))
} }
logic.DeleteInMemoryClient(id)
}, srv)) }, srv))
// can access only with valid token (when logged in), deletes client and creates new one with another secret // can access only with valid token (when logged in), deletes client and creates new one with another secret