Skip to content

Commit fae6001

Browse files
committed
s/Routes/routes in the private router struct
1 parent 30ccfbc commit fae6001

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

handler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,17 @@ func (self *ResourceHandler) SetRoutes(routes ...Route) error {
138138
self.internalRouter = &router{}
139139

140140
for _, route := range routes {
141-
self.internalRouter.Routes = append(
142-
self.internalRouter.Routes,
141+
self.internalRouter.routes = append(
142+
self.internalRouter.routes,
143143
route,
144144
)
145145
}
146146

147147
// add the status route as the last route.
148148
if self.EnableStatusService == true {
149149
self.statusService = newStatusService()
150-
self.internalRouter.Routes = append(
151-
self.internalRouter.Routes,
150+
self.internalRouter.routes = append(
151+
self.internalRouter.routes,
152152
Route{
153153
HttpMethod: "GET",
154154
PathExp: "/.status",

router.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ import (
1010
// support for #param placeholder ?
1111

1212
type router struct {
13-
// list of Routes, the order matters, if multiple Routes match, the first defined will be used.
14-
Routes []Route
13+
routes []Route
1514
disableTrieCompression bool
1615
index map[*Route]int
1716
trie *trie.Trie
1817
}
1918

2019
// This validates the Routes and prepares the Trie data structure.
2120
// It must be called once the Routes are defined and before trying to find Routes.
21+
// The order matters, if multiple Routes match, the first defined will be used.
2222
func (self *router) start() error {
2323

2424
self.trie = trie.New()
2525
self.index = map[*Route]int{}
2626

27-
for i, _ := range self.Routes {
27+
for i, _ := range self.routes {
2828

2929
// pointer to the Route
30-
route := &self.Routes[i]
30+
route := &self.routes[i]
3131

3232
// insert in the Trie
3333
err := self.trie.AddRoute(

router_benchmark_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func BenchmarkNoCompression(b *testing.B) {
5858
b.StopTimer()
5959

6060
r := router{
61-
Routes: routes(),
61+
routes: routes(),
6262
disableTrieCompression: true,
6363
}
6464
r.start()
@@ -78,7 +78,7 @@ func BenchmarkCompression(b *testing.B) {
7878
b.StopTimer()
7979

8080
r := router{
81-
Routes: routes(),
81+
routes: routes(),
8282
}
8383
r.start()
8484
urlObjs := requestUrls()

router_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
func TestFindRouteAPI(t *testing.T) {
99

1010
r := router{
11-
Routes: []Route{
11+
routes: []Route{
1212
Route{
1313
HttpMethod: "GET",
1414
PathExp: "/",
@@ -64,7 +64,7 @@ func TestFindRouteAPI(t *testing.T) {
6464
func TestNoRoute(t *testing.T) {
6565

6666
r := router{
67-
Routes: []Route{},
67+
routes: []Route{},
6868
}
6969

7070
err := r.start()
@@ -89,7 +89,7 @@ func TestNoRoute(t *testing.T) {
8989
func TestDuplicatedRoute(t *testing.T) {
9090

9191
r := router{
92-
Routes: []Route{
92+
routes: []Route{
9393
Route{
9494
HttpMethod: "GET",
9595
PathExp: "/",
@@ -110,7 +110,7 @@ func TestDuplicatedRoute(t *testing.T) {
110110
func TestRouteOrder(t *testing.T) {
111111

112112
r := router{
113-
Routes: []Route{
113+
routes: []Route{
114114
Route{
115115
HttpMethod: "GET",
116116
PathExp: "/r/:id",
@@ -144,7 +144,7 @@ func TestRouteOrder(t *testing.T) {
144144
func TestSimpleExample(t *testing.T) {
145145

146146
r := router{
147-
Routes: []Route{
147+
routes: []Route{
148148
Route{
149149
HttpMethod: "GET",
150150
PathExp: "/resources/:id",

0 commit comments

Comments
 (0)