v1 blog API routes

This commit is contained in:
ari melody 2025-11-07 19:31:34 +00:00
parent fec3325503
commit eaa2f6587d
Signed by: ari
GPG key ID: CF99829C92678188
9 changed files with 286 additions and 34 deletions

View file

@ -99,7 +99,7 @@ func CreateArtist(app *model.AppState) http.Handler {
}
if artist.ID == "" {
http.Error(w, "Artist ID cannot be blank\n", http.StatusBadRequest)
http.Error(w, "Artist ID cannot be blank", http.StatusBadRequest)
return
}
if artist.Name == "" { artist.Name = artist.ID }
@ -107,7 +107,7 @@ func CreateArtist(app *model.AppState) http.Handler {
err = controller.CreateArtist(app.DB, &artist)
if err != nil {
if strings.Contains(err.Error(), "duplicate key") {
http.Error(w, fmt.Sprintf("Artist %s already exists\n", artist.ID), http.StatusBadRequest)
http.Error(w, fmt.Sprintf("Artist %s already exists", artist.ID), http.StatusBadRequest)
return
}
fmt.Printf("WARN: Failed to create artist %s: %s\n", artist.ID, err)