-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.go
54 lines (47 loc) · 2.08 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
package main
import (
"net/http"
"github.com/go-zoo/bone"
"github.com/justinas/alice"
"github.com/NYTimes/gziphandler"
c "github.com/JacksonGariety/cetch/app/controllers"
m "github.com/JacksonGariety/cetch/app/middleware"
)
func NewRouter() http.Handler {
mux := bone.New()
// Middleware
chain := alice.New(
m.Timeout,
gziphandler.GzipHandler,
m.Authenticate,
m.StickyEntry,
)
mux.Get("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
mux.Get("/", chain.ThenFunc(c.Index))
mux.Get("/about", chain.ThenFunc(c.About))
mux.Get("/rules", chain.ThenFunc(c.Rules))
mux.Get("/login", chain.Append(m.Retain).ThenFunc(c.LoginShow))
mux.Post("/login", chain.Append(m.Retain).ThenFunc(c.Login))
mux.Get("/logout", chain.ThenFunc(c.LogoutShow))
mux.Get("/forgotten", chain.Append(m.Retain).ThenFunc(c.ForgottenShow))
mux.Post("/forgotten", chain.Append(m.Retain).ThenFunc(c.ForgottenSendEmail))
mux.Get("/signup", chain.Append(m.Retain).ThenFunc(c.SignupShow))
mux.Post("/signup", chain.Append(m.Retain).ThenFunc(c.SignupPost))
mux.Get("/user/:name", chain.ThenFunc(c.UserShow))
mux.Post("/user/:name", chain.ThenFunc(c.UserShow))
mux.Get("/competitors", chain.ThenFunc(c.UsersShow))
mux.Get("/current", chain.ThenFunc(c.Current))
mux.Get("/competition/new", chain.Append(m.Forbid).ThenFunc(c.CompetitionNew))
mux.Post("/competition/new", chain.Append(m.Forbid).ThenFunc(c.CompetitionCreate))
mux.Get("/competition/:id", chain.ThenFunc(c.CompetitionShow))
mux.Post("/competition/:id", chain.ThenFunc(c.EntryCreate))
mux.Get("/competition/:id/edit", chain.Append(m.Forbid).ThenFunc(c.CompetitionEdit))
mux.Post("/competition/:id/edit", chain.Append(m.Forbid).ThenFunc(c.CompetitionUpdate))
mux.Post("/archive", chain.Append(m.Forbid).ThenFunc(c.Archive))
mux.Get("/archive", chain.ThenFunc(c.Archive))
mux.Get("/schedule", chain.Append(m.Forbid).ThenFunc(c.ScheduleShow))
mux.Post("/schedule", chain.Append(m.Forbid).ThenFunc(c.SchedulePost))
mux.Get("/entry/:id", chain.ThenFunc(c.EntryShow))
mux.Post("/entry/:id", chain.ThenFunc(c.EntryShow))
return mux
}