diff --git a/echo_test.go b/echo_test.go index 4756a2b4..b7a88b58 100644 --- a/echo_test.go +++ b/echo_test.go @@ -121,10 +121,10 @@ func TestEchoMiddleware(t *testing.T) { func TestEchoHandler(t *testing.T) { e := New() - // func(*echo.Context) error - e.Get("/1", func(c *Context) { - c.String(http.StatusOK, "1") - }) + // HandlerFunc + e.Get("/1", HandlerFunc(func(c *Context) error { + return c.String(http.StatusOK, "1") + })) w := httptest.NewRecorder() r, _ := http.NewRequest(GET, "/1", nil) e.ServeHTTP(w, r) @@ -132,9 +132,9 @@ func TestEchoHandler(t *testing.T) { t.Error("body should be 1") } - // HandlerFunc - e.Get("/2", func(c *Context) { - c.String(http.StatusOK, "2") + // func(*echo.Context) error + e.Get("/2", func(c *Context) error { + return c.String(http.StatusOK, "2") }) w = httptest.NewRecorder() r, _ = http.NewRequest(GET, "/2", nil) diff --git a/router.go b/router.go index 67ab6384..5e1dd385 100644 --- a/router.go +++ b/router.go @@ -227,13 +227,14 @@ func (r *router) Find(method, path string, ctx *Context) (h HandlerFunc, echo *E // Search order static > param > match-any for { + // TODO flip condition??? if search == "" || search == cn.prefix || cn.typ == mtype { // Found h = cn.handler echo = cn.echo ctx.pnames = cn.pnames - // Match-any + // Match-any node if cn.typ == mtype { ctx.pvalues[0] = search[len(cn.prefix):] } diff --git a/website/docs/guide.md b/website/docs/guide.md index 5ab96886..d98bbe76 100644 --- a/website/docs/guide.md +++ b/website/docs/guide.md @@ -58,7 +58,7 @@ Echo's router is [fast, optimized](https://github.com/labstack/echo#benchmark) a flexible. It's based on [redix tree](http://en.wikipedia.org/wiki/Radix_tree) data structure which makes routing lookup really fast. It leverages [sync pool](https://golang.org/pkg/sync/#Pool) to reuse memory and achieve -zero dynamic memory allocation with no garbage collection. +zero dynamic memory allocation with no GC overhead. Routes can be registered for any HTTP method, path and handler. For example, code below registers a route for method `GET`, path `/hello` and a handler which sends @@ -167,7 +167,7 @@ with status code. ### String -`context.String(code int, s string) error` can be used to send plain text response +`context.String(code int, s string) error` can be used to send a text/plain response with status code. ### HTML