|
|
- 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()
-
- api.HandleFunc("/posts/front-page", getFrontPagePosts).Methods("GET")
- api.HandleFunc("/post", getPostsPublic).Methods("GET")
- api.HandleFunc("/post/{postID}", getPostPublic).Methods("GET")
-
- // Define routes for posts api
- api.HandleFunc("/admin/post", getPosts).Methods("GET")
- api.HandleFunc("/admin/post/{postID}", getPost).Methods("GET")
-
- api.HandleFunc("/admin/post", createPost).Methods("POST")
- api.HandleFunc("/admin/post/{postID}", updatePost).Methods("PUT")
- api.HandleFunc("/admin/post/{postID}", deletePost).Methods("DELETE")
- api.HandleFunc("/admin/post/{postID}/publish", publishPost).Methods("GET")
-
- api.HandleFunc("/admin/post/{postID}/image", createPostImage).Methods("POST")
- api.HandleFunc("/admin/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}", updateUser).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"))))
- }
|