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