v1 blog API routes
This commit is contained in:
parent
fec3325503
commit
eaa2f6587d
9 changed files with 286 additions and 34 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue