17 lines
384 B
Go
Executable File
17 lines
384 B
Go
Executable File
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"path"
|
|
"strings"
|
|
)
|
|
|
|
func (s *Server) delete(w http.ResponseWriter, r *http.Request) {
|
|
if err := s.Notes.Delete(r.URL.Path); err != nil {
|
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
|
return
|
|
}
|
|
r.URL.Path = strings.Replace(path.Dir(r.URL.Path), "delete", "notes", 1)
|
|
http.Redirect(w, r, r.URL.String(), http.StatusPermanentRedirect)
|
|
}
|