From 8adce860b7aac08d37c4cde9e61a28c2b0e64723 Mon Sep 17 00:00:00 2001 From: Redume Date: Mon, 19 Sep 2022 02:06:03 +0300 Subject: [PATCH] set wallpaper from api --- api/controllers/wallpaper.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 api/controllers/wallpaper.go diff --git a/api/controllers/wallpaper.go b/api/controllers/wallpaper.go new file mode 100644 index 0000000..af1c42d --- /dev/null +++ b/api/controllers/wallpaper.go @@ -0,0 +1,23 @@ +package controllers + +import ( + "github.com/Redume/EveryNasa/api/utils" + "github.com/reujab/wallpaper" + "net/http" +) + +var WallpaperUpdate = func(w http.ResponseWriter, r *http.Request) { + var url string + + url = r.FormValue("url") + + if url == "" { + utils.Respond(w, utils.Message(false, "URL is required")) + return + } + + err := wallpaper.SetFromURL(url) + if err != nil { + panic(err) + } +}