package Api import ( "log" "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Api/Auth" "github.com/gorilla/mux" ) func InitApiEndpoints() *mux.Router { var ( router *mux.Router ) log.Println("Initializing API routes...") router = mux.NewRouter() // Define routes for posts api router.HandleFunc("/post", getPosts).Methods("GET") router.HandleFunc("/post", createPost).Methods("POST") router.HandleFunc("/post/{postID}", getPost).Methods("GET") router.HandleFunc("/post/{postID}", updatePost).Methods("PUT") router.HandleFunc("/post/{postID}", deletePost).Methods("DELETE") router.HandleFunc("/frontPagePosts", getFrontPagePosts).Methods("GET") router.HandleFunc("/post/{postID}/image", createPostImage).Methods("POST") router.HandleFunc("/post/{postID}/image/{imageID}", deletePostImage).Methods("DELETE") // Define routes for users api router.HandleFunc("/admin/user", getUsers).Methods("GET") router.HandleFunc("/admin/user", createUser).Methods("POST") router.HandleFunc("/admin/user/{userID}", getUser).Methods("GET") router.HandleFunc("/admin/user/{userID}", updatePost).Methods("PUT") router.HandleFunc("/admin/user/{userID}", deletePost).Methods("DELETE") router.HandleFunc("/admin/user/{userID}/update-password", Auth.UpdatePassword).Methods("PUT") // Define routes for authentication router.HandleFunc("/admin/login", Auth.Login).Methods("POST") router.HandleFunc("/admin/logout", Auth.Logout).Methods("GET") //router.PathPrefix("/").Handler(http.StripPrefix("/images/", http.FileServer(http.Dir("./uploads")))) return router }