From 4786fb0948384c7375723eca117db52852791709 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 10 Jun 2014 20:12:57 +0800 Subject: [PATCH] beego:fix typo NewControllerRegister --- app.go | 2 +- filter_test.go | 6 +++--- flash_test.go | 2 +- namespace.go | 2 +- router.go | 4 ++-- router_test.go | 36 ++++++++++++++++++------------------ 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app.go b/app.go index bcfa0564..26e565c5 100644 --- a/app.go +++ b/app.go @@ -27,7 +27,7 @@ type App struct { // NewApp returns a new beego application. func NewApp() *App { - cr := NewControllerRegistor() + cr := NewControllerRegister() app := &App{Handlers: cr, Server: &http.Server{}} return app } diff --git a/filter_test.go b/filter_test.go index 4f0880e3..e5428b96 100644 --- a/filter_test.go +++ b/filter_test.go @@ -21,7 +21,7 @@ var FilterUser = func(ctx *context.Context) { func TestFilter(t *testing.T) { r, _ := http.NewRequest("GET", "/person/asta/Xie", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.InsertFilter("/person/:last/:first", BeforeRouter, FilterUser) handler.Add("/person/:last/:first", &TestController{}) handler.ServeHTTP(w, r) @@ -40,7 +40,7 @@ var FilterAdminUser = func(ctx *context.Context) { func TestPatternTwo(t *testing.T) { r, _ := http.NewRequest("GET", "/admin/", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.InsertFilter("/admin/?:all", BeforeRouter, FilterAdminUser) handler.ServeHTTP(w, r) if w.Body.String() != "i am admin" { @@ -51,7 +51,7 @@ func TestPatternTwo(t *testing.T) { func TestPatternThree(t *testing.T) { r, _ := http.NewRequest("GET", "/admin/astaxie", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.InsertFilter("/admin/:all", BeforeRouter, FilterAdminUser) handler.ServeHTTP(w, r) if w.Body.String() != "i am admin" { diff --git a/flash_test.go b/flash_test.go index 40eddabb..f0a17480 100644 --- a/flash_test.go +++ b/flash_test.go @@ -31,7 +31,7 @@ func TestFlashHeader(t *testing.T) { w := httptest.NewRecorder() // setup the handler - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Add("/", &TestFlashController{}, "get:TestWriteFlash") handler.ServeHTTP(w, r) diff --git a/namespace.go b/namespace.go index 26371af7..ca902788 100644 --- a/namespace.go +++ b/namespace.go @@ -26,7 +26,7 @@ type Namespace struct { func NewNamespace(prefix string, params ...innnerNamespace) *Namespace { ns := &Namespace{ prefix: prefix, - handlers: NewControllerRegistor(), + handlers: NewControllerRegister(), } for _, p := range params { p(ns) diff --git a/router.go b/router.go index 34f0e914..32e0ff35 100644 --- a/router.go +++ b/router.go @@ -75,8 +75,8 @@ type ControllerRegistor struct { filters map[int][]*FilterRouter } -// NewControllerRegistor returns a new ControllerRegistor. -func NewControllerRegistor() *ControllerRegistor { +// NewControllerRegister returns a new ControllerRegistor. +func NewControllerRegister() *ControllerRegistor { return &ControllerRegistor{ routers: make(map[string]*Tree), filters: make(map[int][]*FilterRouter), diff --git a/router_test.go b/router_test.go index 267e8569..2f770485 100644 --- a/router_test.go +++ b/router_test.go @@ -72,7 +72,7 @@ func (this *JsonController) Get() { } func TestUrlFor(t *testing.T) { - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Add("/api/list", &TestController{}, "*:List") handler.Add("/person/:last/:first", &TestController{}) handler.AddAuto(&TestController{}) @@ -95,7 +95,7 @@ func TestUserFunc(t *testing.T) { r, _ := http.NewRequest("GET", "/api/list", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Add("/api/list", &TestController{}, "*:List") handler.ServeHTTP(w, r) if w.Body.String() != "i am list" { @@ -107,7 +107,7 @@ func TestPostFunc(t *testing.T) { r, _ := http.NewRequest("POST", "/astaxie", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Add("/:name", &TestController{}) handler.ServeHTTP(w, r) if w.Body.String() != "astaxie" { @@ -119,7 +119,7 @@ func TestAutoFunc(t *testing.T) { r, _ := http.NewRequest("GET", "/test/list", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.AddAuto(&TestController{}) handler.ServeHTTP(w, r) if w.Body.String() != "i am list" { @@ -131,7 +131,7 @@ func TestAutoFuncParams(t *testing.T) { r, _ := http.NewRequest("GET", "/test/params/2009/11/12", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.AddAuto(&TestController{}) handler.ServeHTTP(w, r) if w.Body.String() != "20091112" { @@ -143,7 +143,7 @@ func TestAutoExtFunc(t *testing.T) { r, _ := http.NewRequest("GET", "/test/myext.json", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.AddAuto(&TestController{}) handler.ServeHTTP(w, r) if w.Body.String() != "json" { @@ -156,7 +156,7 @@ func TestRouteOk(t *testing.T) { r, _ := http.NewRequest("GET", "/person/anderson/thomas?learn=kungfu", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Add("/person/:last/:first", &TestController{}, "get:GetParams") handler.ServeHTTP(w, r) body := w.Body.String() @@ -170,7 +170,7 @@ func TestManyRoute(t *testing.T) { r, _ := http.NewRequest("GET", "/beego32-12.html", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Add("/beego:id([0-9]+)-:page([0-9]+).html", &TestController{}, "get:GetManyRouter") handler.ServeHTTP(w, r) @@ -185,7 +185,7 @@ func TestNotFound(t *testing.T) { r, _ := http.NewRequest("GET", "/", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.ServeHTTP(w, r) if w.Code != http.StatusNotFound { @@ -199,7 +199,7 @@ func TestStatic(t *testing.T) { r, _ := http.NewRequest("GET", "/static/js/jquery.js", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.ServeHTTP(w, r) if w.Code != 404 { @@ -211,7 +211,7 @@ func TestPrepare(t *testing.T) { r, _ := http.NewRequest("GET", "/json/list", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Add("/json/list", &JsonController{}) handler.ServeHTTP(w, r) if w.Body.String() != `"prepare"` { @@ -223,7 +223,7 @@ func TestAutoPrefix(t *testing.T) { r, _ := http.NewRequest("GET", "/admin/test/list", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.AddAutoPrefix("/admin", &TestController{}) handler.ServeHTTP(w, r) if w.Body.String() != "i am list" { @@ -235,7 +235,7 @@ func TestRouterGet(t *testing.T) { r, _ := http.NewRequest("GET", "/user", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Get("/user", func(ctx *context.Context) { ctx.Output.Body([]byte("Get userlist")) }) @@ -249,7 +249,7 @@ func TestRouterPost(t *testing.T) { r, _ := http.NewRequest("POST", "/user/123", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Post("/user/:id", func(ctx *context.Context) { ctx.Output.Body([]byte(ctx.Input.Param(":id"))) }) @@ -267,7 +267,7 @@ func TestRouterHandler(t *testing.T) { r, _ := http.NewRequest("POST", "/sayhi", nil) w := httptest.NewRecorder() - handler := NewControllerRegistor() + handler := NewControllerRegister() handler.Handler("/sayhi", http.HandlerFunc(sayhello)) handler.ServeHTTP(w, r) if w.Body.String() != "sayhello" { @@ -292,7 +292,7 @@ func (a *AdminController) Get() { } func TestRouterFunc(t *testing.T) { - mux := NewControllerRegistor() + mux := NewControllerRegister() mux.Get("/action", beegoFilterFunc) mux.Post("/action", beegoFilterFunc) rw, r := testRequest("GET", "/action") @@ -303,7 +303,7 @@ func TestRouterFunc(t *testing.T) { } func BenchmarkFunc(b *testing.B) { - mux := NewControllerRegistor() + mux := NewControllerRegister() mux.Get("/action", beegoFilterFunc) rw, r := testRequest("GET", "/action") b.ResetTimer() @@ -313,7 +313,7 @@ func BenchmarkFunc(b *testing.B) { } func BenchmarkController(b *testing.B) { - mux := NewControllerRegistor() + mux := NewControllerRegister() mux.Add("/action", &AdminController{}) rw, r := testRequest("GET", "/action") b.ResetTimer()