Added answers from api about errors and successful wallpaper change

This commit is contained in:
Данил 2022-10-02 12:21:25 +03:00
parent 45fe8f981e
commit 7ba118f9b6

View file

@ -1,10 +1,11 @@
package controllers
import (
"net/http"
"github.com/Redume/EveryNasa/api/utils"
"github.com/Redume/EveryNasa/functions"
"github.com/reujab/wallpaper"
"net/http"
)
var WallpaperUpdate = func(w http.ResponseWriter, r *http.Request) {
@ -18,5 +19,9 @@ var WallpaperUpdate = func(w http.ResponseWriter, r *http.Request) {
err := wallpaper.SetFromURL(url)
if err != nil {
functions.Logger(err.Error())
utils.Respond(w, utils.Message(false, "An error occurred while setting the wallpaper"))
return
}
utils.Respond(w, utils.Message(true, "Wallpaper successfully updated"))
}