-
Notifications
You must be signed in to change notification settings - Fork 316
/
Copy pathroutes.go
95 lines (92 loc) · 2.15 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package web
import (
"github.com/RichardKnop/go-oauth2-server/util/routes"
"github.com/gorilla/mux"
"github.com/urfave/negroni"
)
// RegisterRoutes registers route handlers for the health service
func (s *Service) RegisterRoutes(router *mux.Router, prefix string) {
subRouter := router.PathPrefix(prefix).Subrouter()
routes.AddRoutes(s.GetRoutes(), subRouter)
}
// GetRoutes returns []routes.Route slice for the health service
func (s *Service) GetRoutes() []routes.Route {
return []routes.Route{
{
Name: "register_form",
Method: "GET",
Pattern: "/register",
HandlerFunc: s.registerForm,
Middlewares: []negroni.Handler{
new(parseFormMiddleware),
newGuestMiddleware(s),
newClientMiddleware(s),
},
},
{
Name: "register",
Method: "POST",
Pattern: "/register",
HandlerFunc: s.register,
Middlewares: []negroni.Handler{
new(parseFormMiddleware),
newGuestMiddleware(s),
newClientMiddleware(s),
},
},
{
Name: "login_form",
Method: "GET",
Pattern: "/login",
HandlerFunc: s.loginForm,
Middlewares: []negroni.Handler{
new(parseFormMiddleware),
newGuestMiddleware(s),
newClientMiddleware(s),
},
},
{
Name: "login",
Method: "POST",
Pattern: "/login",
HandlerFunc: s.login,
Middlewares: []negroni.Handler{
new(parseFormMiddleware),
newGuestMiddleware(s),
newClientMiddleware(s),
},
},
{
Name: "logout",
Method: "GET",
Pattern: "/logout",
HandlerFunc: s.logout,
Middlewares: []negroni.Handler{
new(parseFormMiddleware),
newLoggedInMiddleware(s),
},
},
{
Name: "authorize_form",
Method: "GET",
Pattern: "/authorize",
HandlerFunc: s.authorizeForm,
Middlewares: []negroni.Handler{
new(parseFormMiddleware),
newLoggedInMiddleware(s),
newClientMiddleware(s),
},
},
{
Name: "authorize",
Method: "POST",
Pattern: "/authorize",
HandlerFunc: s.authorize,
Middlewares: []negroni.Handler{
new(parseFormMiddleware),
newLoggedInMiddleware(s),
newClientMiddleware(s),
},
},
}
}