1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Updated website

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-05-13 15:49:09 -07:00
parent ba05b6e58e
commit 8abd4faf08
3 changed files with 17 additions and 9 deletions

View File

@ -293,7 +293,7 @@ func (e *Echo) add(method, path string, h Handler) {
// Static serves static files. // Static serves static files.
func (e *Echo) Static(path, root string) { func (e *Echo) Static(path, root string) {
fs := http.StripPrefix(path, http.FileServer(http.Dir(root))) 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) fs.ServeHTTP(c.Response, c.Request)
return nil return nil
}) })

View File

@ -89,7 +89,7 @@ func main() {
e.Favicon("public/favicon.ico") e.Favicon("public/favicon.ico")
// Serve static files // Serve static files
e.Static("/scripts", "public/scripts") e.Static("/scripts/", "public/scripts")
//-------- //--------
// Routes // Routes

View File

@ -193,18 +193,17 @@ Sends an HTML HTTP response with status code.
### Static files ### Static files
`echo.Static(path, root string)` serves static files. For example, code below `echo.Static(path, root string)` serves static files. For example, code below serves
serves all files from `public/scripts` directory for any path starting files from directory `public/scripts` for any URL path starting with `/scripts/`.
with `/scripts/`
```go ```go
e.Static("/scripts", "public/scripts") e.Static("/scripts/", "public/scripts")
``` ```
### Serving a file ### Serving a file
`echo.ServeFile(path, file string)` serves a file. For example, code below serves `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 ```go
e.ServeFile("/welcome", "welcome.html") e.ServeFile("/welcome", "welcome.html")
@ -212,13 +211,22 @@ e.ServeFile("/welcome", "welcome.html")
### Serving an index file ### Serving an index file
`echo.Index(file string)` serves an index file. For example, code below serves `echo.Index(file string)` serves an index file. For example, code below serves file
index.html for path `/` `index.html`.
```go ```go
e.Index("index.html") 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 ## Error Handling
Echo advocates centralized HTTP error handling by returning `*echo.HTTPError` from Echo advocates centralized HTTP error handling by returning `*echo.HTTPError` from