From 5e1dc9d5c50ae7b6e76a3a653bfc8d3dc08b5adb Mon Sep 17 00:00:00 2001 From: Redume Date: Sun, 2 Oct 2022 12:24:00 +0300 Subject: [PATCH] api compactification --- main.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 014c25e..0b2924a 100644 --- a/main.go +++ b/main.go @@ -11,16 +11,11 @@ import ( ) func main() { + go functions.Logger("EveryNasa started") go functions.Database() go systray.Run(functions.Tray, functions.Quit) go functions.StartWallpaper() - http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./web/static")))) - - http.HandleFunc("/", page.GalleryHandler) - http.HandleFunc("/settings", page.SettingsHandler) - http.HandleFunc("/about", page.AboutHandler) - router := mux.NewRouter() router.Use(func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -31,12 +26,19 @@ func main() { }) }) + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./web/static")))) + + http.HandleFunc("/", page.GalleryHandler) + http.HandleFunc("/settings", page.SettingsHandler) + http.HandleFunc("/about", page.AboutHandler) + router.HandleFunc("/api/get/settings", controllers.SettingsGet).Methods("GET") router.HandleFunc("/api/get/version", controllers.Version).Methods("GET") + router.HandleFunc("/api/update/settings", controllers.SettingsUpdate).Methods("POST") router.HandleFunc("/api/update/wallpaper", controllers.WallpaperUpdate).Methods("POST") - router.HandleFunc("/api/update/set/startup", controllers.SetStartup).Methods("POST") - router.HandleFunc("/api/update/del/startup", controllers.RemoveStartup).Methods("POST") + router.HandleFunc("/api/update/startup", controllers.Startup).Methods("POST") + router.HandleFunc("/api/create/label", controllers.CreateLabel).Methods("POST") go func() { err := http.ListenAndServe(":4662", nil)