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("/user", getUsers).Methods("GET") router.HandleFunc("/user", createUser).Methods("POST") router.HandleFunc("/user/{userID}", getUser).Methods("GET") router.HandleFunc("/user/{userID}", updatePost).Methods("PUT") router.HandleFunc("/user/{userID}", deletePost).Methods("DELETE") // 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 }