Created
May 4, 2019 19:11
-
-
Save linux08/b0e939193ad4336659dfc11a7b59a60b to your computer and use it in GitHub Desktop.
This file contains 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
func Handlers() *mux.Router { | |
r := mux.NewRouter().StrictSlash(true) | |
r.Use(CommonMiddleware) | |
r.HandleFunc("/", controllers.TestAPI).Methods("GET") | |
r.HandleFunc("/api", controllers.TestAPI).Methods("GET") | |
r.HandleFunc("/register", controllers.CreateUser).Methods("POST") | |
r.HandleFunc("/login", controllers.Login).Methods("POST") | |
// Auth route | |
s := r.PathPrefix("/auth").Subrouter() | |
s.Use(auth.JwtVerify) | |
s.HandleFunc("/user", controllers.FetchUsers).Methods("GET") | |
s.HandleFunc("/user/{id}", controllers.GetUser).Methods("GET") | |
s.HandleFunc("/user/{id}", controllers.UpdateUser).Methods("PUT") | |
s.HandleFunc("/user/{id}", controllers.DeleteUser).Methods("DELETE") | |
return r | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment