28 lines
509 B
Go
28 lines
509 B
Go
package datasets
|
|
|
|
import (
|
|
"gis/app"
|
|
"net/http"
|
|
)
|
|
|
|
func deleteDatasetRoute(application *app.App) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
id := r.PathValue("id")
|
|
|
|
tag, err := application.Db.Exec(application.Ctx,
|
|
"DELETE FROM datasets WHERE id=$1",
|
|
id,
|
|
)
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
return
|
|
}
|
|
if tag.RowsAffected() == 0 {
|
|
w.WriteHeader(http.StatusNotFound)
|
|
return
|
|
}
|
|
|
|
w.WriteHeader(http.StatusNoContent)
|
|
}
|
|
}
|