You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
985 B

  1. package Api
  2. import (
  3. "log"
  4. "github.com/gorilla/mux"
  5. )
  6. func InitApiEndpoints() *mux.Router {
  7. var (
  8. router *mux.Router
  9. )
  10. log.Println("Initializing API routes...")
  11. router = mux.NewRouter()
  12. // Define routes for posts api
  13. router.HandleFunc("/post", getPosts).Methods("GET")
  14. router.HandleFunc("/frontPagePosts", getFrontPagePosts).Methods("GET")
  15. router.HandleFunc("/post", createPost).Methods("POST")
  16. router.HandleFunc("/post/{postID}", createPost).Methods("GET")
  17. router.HandleFunc("/post/{postID}", updatePost).Methods("PUT")
  18. router.HandleFunc("/post/{postID}", deletePost).Methods("DELETE")
  19. router.HandleFunc("/post/{postID}/image", createPostImage).Methods("POST")
  20. router.HandleFunc("/post/{postID}/image/{imageID}", deletePostImage).Methods("DELETE")
  21. // Define routes for users api
  22. router.HandleFunc("/user", createUser).Methods("POST")
  23. //router.PathPrefix("/").Handler(http.StripPrefix("/images/", http.FileServer(http.Dir("./uploads"))))
  24. return router
  25. }