From 8abd4faf083b355a7b4662dd6752e372c3572be0 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Wed, 13 May 2015 15:49:09 -0700 Subject: [PATCH] Updated website Signed-off-by: Vishal Rana --- echo.go | 2 +- examples/web/server.go | 2 +- website/docs/guide.md | 22 +++++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/echo.go b/echo.go index 5a74c0bb..6a16b514 100644 --- a/echo.go +++ b/echo.go @@ -293,7 +293,7 @@ func (e *Echo) add(method, path string, h Handler) { // Static serves static files. func (e *Echo) Static(path, root string) { fs := http.StripPrefix(path, http.FileServer(http.Dir(root))) - e.Get(path+"/*", func(c *Context) *HTTPError { + e.Get(path+"*", func(c *Context) *HTTPError { fs.ServeHTTP(c.Response, c.Request) return nil }) diff --git a/examples/web/server.go b/examples/web/server.go index a1aaf570..ba321230 100644 --- a/examples/web/server.go +++ b/examples/web/server.go @@ -89,7 +89,7 @@ func main() { e.Favicon("public/favicon.ico") // Serve static files - e.Static("/scripts", "public/scripts") + e.Static("/scripts/", "public/scripts") //-------- // Routes diff --git a/website/docs/guide.md b/website/docs/guide.md index 930c2dfa..9f49fcc7 100644 --- a/website/docs/guide.md +++ b/website/docs/guide.md @@ -193,18 +193,17 @@ Sends an HTML HTTP response with status code. ### Static files -`echo.Static(path, root string)` serves static files. For example, code below -serves all files from `public/scripts` directory for any path starting -with `/scripts/` +`echo.Static(path, root string)` serves static files. For example, code below serves +files from directory `public/scripts` for any URL path starting with `/scripts/`. ```go -e.Static("/scripts", "public/scripts") +e.Static("/scripts/", "public/scripts") ``` ### Serving a file `echo.ServeFile(path, file string)` serves a file. For example, code below serves -welcome.html for path `/welcome` +file `welcome.html` for URL path `/welcome`. ```go e.ServeFile("/welcome", "welcome.html") @@ -212,13 +211,22 @@ e.ServeFile("/welcome", "welcome.html") ### Serving an index file -`echo.Index(file string)` serves an index file. For example, code below serves -index.html for path `/` +`echo.Index(file string)` serves an index file. For example, code below serves file +`index.html`. ```go e.Index("index.html") ``` +### Serving favicon + +`echo.Favicon(file string)` serves default favicon - `GET /favicon.ico`. For example, +code below serves file `favicon.ico`. + +```go +e.Index("public/favicon.ico") +``` + ## Error Handling Echo advocates centralized HTTP error handling by returning `*echo.HTTPError` from