27 lines
507 B
Go
27 lines
507 B
Go
package routes
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"tomatentum.net/svg-templater/pkg/svg/actions"
|
|
)
|
|
|
|
func DeleteSvg(writer http.ResponseWriter, reader *http.Request) {
|
|
|
|
id := reader.PathValue("id")
|
|
if id == "" {
|
|
http.Error(writer, "No ID provided", http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
success, err := actions.Delete(id)
|
|
if err != nil {
|
|
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
if !success {
|
|
http.Error(writer, "No template to delete.", http.StatusBadRequest)
|
|
return
|
|
}
|
|
}
|