-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.go
41 lines (32 loc) · 802 Bytes
/
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
package main
import (
"net/http"
)
type RouteType int
const (
UNSECURED RouteType = 1 + iota
SECURED
)
var routeTypes = [...]string {
"unsecured",
"secured",
}
func (rtype RouteType) String() string {
return routeTypes[rtype - 1]
}
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
rtype RouteType
}
type Routes []Route
var routes = Routes {
Route {"Index", "GET", "/", Index, UNSECURED},
Route {"Add", "POST", "/notes", Add, SECURED},
Route {"Remove", "DELETE", "/notes/{noteId}", Remove, SECURED},
Route {"Find", "GET", "/notes/{noteId}", Find, SECURED},
Route {"List", "GET", "/notes", List, SECURED},
//Route {"User", "GET", "/user", UserHandler, SECURED},
}