Starlio-web/api/controllers/wallpaper.go

29 lines
639 B
Go
Raw Normal View History

2022-09-19 02:06:03 +03:00
package controllers
import (
"github.com/Redume/EveryNasa/api/utils"
2022-09-25 11:04:39 +03:00
"github.com/Redume/EveryNasa/functions"
"github.com/gofiber/fiber/v2"
2022-09-19 02:06:03 +03:00
"github.com/reujab/wallpaper"
)
var WallpaperUpdate = func(c *fiber.Ctx) error {
2022-09-19 02:06:03 +03:00
var url string
url = c.FormValue("url")
2022-09-19 02:06:03 +03:00
if url == "" {
utils.Respond(c, utils.Message(false, "URL is required"))
return nil
2022-09-19 02:06:03 +03:00
}
err := wallpaper.SetFromURL(url)
if err != nil {
2022-09-25 11:04:39 +03:00
functions.Logger(err.Error())
utils.Respond(c, utils.Message(false, "An error occurred while setting the wallpaper"))
return nil
2022-09-19 02:06:03 +03:00
}
utils.Respond(c, utils.Message(true, "Wallpaper successfully updated"))
return nil
2022-09-19 02:06:03 +03:00
}