-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.go
36 lines (32 loc) · 1.41 KB
/
routes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"./controllers"
"./utilities"
"github.com/gorilla/mux"
)
func LoadRoutes() *mux.Router {
index := controllers.Index{}
auth := controllers.Auth{}
user := controllers.User{}
assignment := controllers.Assignment{}
problem := controllers.Problem{}
router := mux.NewRouter()
router.HandleFunc("/", index.Welcome).Methods("GET")
router.HandleFunc("/sitemap", index.Sitemap)
a := router.PathPrefix("/auth").Subrouter()
a.HandleFunc("/login", auth.Login).Methods("POST")
a.HandleFunc("/logout", auth.Logout).Methods("GET")
a.HandleFunc("/user", auth.User).Methods("GET")
a.HandleFunc("/register", auth.Register).Methods("POST")
a = router.PathPrefix("/users").Subrouter()
a.HandleFunc("/profile", utilities.AuthenticationHandler(user.Profile)).Methods("GET")
// Adding problem-submission code from here
a.HandleFunc("/assignment", utilities.AuthenticationHandler(user.Profile)).Methods("GET")
a.HandleFunc("/{id}", utilities.AuthenticationHandler(user.Get)).Methods("GET")
a = router.PathPrefix("/create").Subrouter()
// Adding assignment-submission code from here
a.HandleFunc("/assignment", utilities.AuthenticationHandler(assignment.Create_assignment)).Methods("POST")
a.HandleFunc("/problem", utilities.AuthenticationHandler(problem.Create_problem)).Methods("POST")
router.HandleFunc("/assignment/{id}", utilities.AuthenticationHandler(problem.Get_Assignment)).Methods("GET")
return router
}