chore(tfstated): use a struct{} as context.Context key

This commit is contained in:
Julien Dessaux 2024-11-15 23:48:35 +01:00
parent 3d8812fbd0
commit 478f42f8a9
Signed by: adyxax
GPG key ID: F92E51B86E07177E
3 changed files with 5 additions and 2 deletions

View file

@ -25,7 +25,7 @@ func handlePost(db *database.DB) http.Handler {
_ = errorResponse(w, http.StatusBadRequest, err)
return
}
account := r.Context().Value("account").(*model.Account)
account := r.Context().Value(model.AccountContextKey{}).(*model.Account)
if idMismatch, err := db.SetState(r.URL.Path, account.Id, data, id); err != nil {
if idMismatch {
_ = errorResponse(w, http.StatusConflict, err)