diff options
| -rw-r--r-- | context.go | 22 | ||||
| -rw-r--r-- | engine.go | 2 | ||||
| -rw-r--r-- | group.go | 4 | ||||
| -rw-r--r-- | group_test.go | 42 | ||||
| -rw-r--r-- | parser_test.go | 2 |
5 files changed, 27 insertions, 45 deletions
@@ -44,9 +44,9 @@ func (c *Context) XML(code int, data string) { // error, message, status func (c *Context) Error(code int, msg string) { c.JSON(code, map[string]string{ - "error": http.StatusText(code), + "error": http.StatusText(code), "message": msg, - "status": strconv.Itoa(code), + "status": strconv.Itoa(code), }) } @@ -101,13 +101,13 @@ func (c *Context) SetCompleteCookie(cookie *http.Cookie) { func (c *Context) SetCookie(name string, value string) { cookie := http.Cookie{ - Name: name, - Value: value, - Path: "/", - MaxAge: 3600, - HttpOnly: true, - Secure: true, - SameSite: http.SameSiteLaxMode, - } - c.SetCompleteCookie(&cookie) + Name: name, + Value: value, + Path: "/", + MaxAge: 3600, + HttpOnly: true, + Secure: true, + SameSite: http.SameSiteLaxMode, + } + c.SetCompleteCookie(&cookie) } @@ -42,7 +42,7 @@ func (a *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) { W: w, R: req, Params: params, - Querys: query, + Querys: query, }) } @@ -20,8 +20,8 @@ func (e *Engine) Group(prefix string, fn func(*Group)) { // Group.Group creates a nested Group // joining all prefixes of parent groups -func(g *Group) Group(prefix string, fn func(*Group)) { - nested := &Group { +func (g *Group) Group(prefix string, fn func(*Group)) { + nested := &Group{ prefix: joinPath(g.prefix, prefix), engine: g.engine, } diff --git a/group_test.go b/group_test.go index e682f09..e1ceca4 100644 --- a/group_test.go +++ b/group_test.go @@ -6,12 +6,6 @@ import ( "testing" ) -/* - ====================================================== - Test Group() - ====================================================== -*/ - func TestGroupCallback(t *testing.T) { e := New() @@ -32,12 +26,6 @@ func TestGroupCallback(t *testing.T) { } } -/* - ====================================================== - Test route registration - ====================================================== -*/ - func TestGroupRouteRegistration(t *testing.T) { e := New() @@ -81,24 +69,6 @@ func TestGroupRouteRegistration(t *testing.T) { } } -// helper: convert []string{"api","ping"} → "api/ping" -func joinParts(parts []string) string { - out := "" - for i, p := range parts { - if i > 0 { - out += "/" - } - out += p - } - return out -} - -/* - ====================================================== - End-to-End ServeHTTP test - ====================================================== -*/ - func TestGroupServeHTTP(t *testing.T) { e := New() @@ -121,3 +91,15 @@ func TestGroupServeHTTP(t *testing.T) { t.Fatalf("expected body 'ok', got '%s'", body) } } + +// helper: convert []string{"api","ping"} → "api/ping" +func joinParts(parts []string) string { + out := "" + for i, p := range parts { + if i > 0 { + out += "/" + } + out += p + } + return out +} diff --git a/parser_test.go b/parser_test.go index c63f758..cf00017 100644 --- a/parser_test.go +++ b/parser_test.go @@ -34,7 +34,7 @@ func TestRouterSplitPath(t *testing.T) { func TestExtractQueryStr(t *testing.T) { tests := []struct { input string - want1 string + want1 string want2 string }{ {"", "", ""}, |
