|
|
- package Api
-
- import (
- "log"
-
- "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("/frontPagePosts", getFrontPagePosts).Methods("GET")
- router.HandleFunc("/post", createPost).Methods("POST")
- router.HandleFunc("/post/{postID}", createPost).Methods("GET")
- router.HandleFunc("/post/{postID}", updatePost).Methods("PUT")
- router.HandleFunc("/post/{postID}", deletePost).Methods("DELETE")
-
- //router.PathPrefix("/").Handler(http.StripPrefix("/images/", http.FileServer(http.Dir("./uploads"))))
-
- return router
- }
|