Fix delete behaviour
This commit is contained in:
parent
0498aadcf2
commit
a955c49373
2 changed files with 15 additions and 6 deletions
|
|
@ -107,10 +107,18 @@ func new(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func delete(w http.ResponseWriter, r *http.Request) {
|
||||
// user := r.Context().Value(middleware.ContextKey("user")).(string)
|
||||
user := r.Context().Value(middleware.ContextKey("user")).(string)
|
||||
|
||||
uid := r.PathValue("note")
|
||||
|
||||
note, ok := notes.Notes.GetOne(user, uid)
|
||||
|
||||
if !ok {
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
|
||||
err := notes.Notes.Del(note, user)
|
||||
|
||||
encodedTitle := r.PathValue("note")
|
||||
err := notes.DeleteNote(encodedTitle)
|
||||
if err != nil {
|
||||
log.Print(err.Error())
|
||||
http.Error(w, "Couldn't delete note", http.StatusInternalServerError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue