Created
July 23, 2019 17:27
-
-
Save schadokar/64b8dd130b93de6a4f43f1ac5325f2b8 to your computer and use it in GitHub Desktop.
go-todo router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package router | |
| import ( | |
| "../middleware" | |
| "github.com/gorilla/mux" | |
| ) | |
| // Router is exported and used in main.go | |
| func Router() *mux.Router { | |
| router := mux.NewRouter() | |
| router.HandleFunc("/api/task", middleware.GetAllTask).Methods("GET", "OPTIONS") | |
| router.HandleFunc("/api/task", middleware.CreateTask).Methods("POST", "OPTIONS") | |
| router.HandleFunc("/api/task/{id}", middleware.TaskComplete).Methods("PUT", "OPTIONS") | |
| router.HandleFunc("/api/undoTask/{id}", middleware.UndoTask).Methods("PUT", "OPTIONS") | |
| router.HandleFunc("/api/deleteTask/{id}", middleware.DeleteTask).Methods("DELETE", "OPTIONS") | |
| router.HandleFunc("/api/deleteAllTask", middleware.DeleteAllTask).Methods("DELETE", "OPTIONS") | |
| return router | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment