-
Notifications
You must be signed in to change notification settings - Fork 0
/
urls.go
52 lines (47 loc) · 1.3 KB
/
urls.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
package heron
import (
"github.com/zenazn/goji"
"github.com/zenazn/goji/web"
)
type Route struct {
url string
methods []string
handler web.HandlerType
}
var routes = []Route{
{"/apis/accounts", []string{"POST"}, AccountController},
{"/apis/accounts/:username", []string{"GET"}, AccountController},
{"/apis/accounts/sign", []string{"POST", "DELETE"}, AccountSignController},
{"/apis/events", []string{"GET", "POST"}, EventsController},
{"/apis/events/:eid", []string{"GET", "DELETE"}, EventController},
{"/apis/follows", []string{"POST"}, FollowsController},
{"/apis/follows/:fid", []string{"DELETE"}, FollowController},
{"/", []string{"GET"}, IndexController},
{"/account/signin", []string{"GET"}, AccountSignInViewController},
{"/account/signup", []string{"GET"}, AccountSignUpViewController},
}
func SetupRoutes() {
for _, route := range routes {
for _, method := range route.methods {
switch method {
case "GET":
goji.Get(route.url, route.handler)
break
case "POST":
goji.Post(route.url, route.handler)
break
case "PUT":
goji.Put(route.url, route.handler)
break
case "PATCH":
goji.Patch(route.url, route.handler)
break
case "DELETE":
goji.Delete(route.url, route.handler)
break
default:
goji.Handle(route.url, route.handler)
}
}
}
}