fix /delete
This commit is contained in:
parent
b0d9c95f9d
commit
aa64be3c24
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue