2015-10-02 03:24:38 +02:00
|
|
|
---
|
|
|
|
title: Index
|
|
|
|
---
|
|
|
|
|
2016-01-30 20:05:17 +02:00
|
|
|
# ![Echo](/images/echo.svg) Echo
|
2015-04-20 07:04:30 +02:00
|
|
|
|
2015-10-02 03:24:38 +02:00
|
|
|
A fast and unfancy micro web framework for Go.
|
2015-04-20 07:04:30 +02:00
|
|
|
|
|
|
|
---
|
|
|
|
|
2015-04-19 06:53:38 +02:00
|
|
|
## Features
|
|
|
|
|
2015-06-18 23:40:48 +02:00
|
|
|
- Fast HTTP router which smartly prioritize routes.
|
2015-06-03 18:20:32 +02:00
|
|
|
- Extensible middleware, supports:
|
|
|
|
- `echo.MiddlewareFunc`
|
|
|
|
- `func(echo.HandlerFunc) echo.HandlerFunc`
|
|
|
|
- `echo.HandlerFunc`
|
|
|
|
- `func(*echo.Context) error`
|
|
|
|
- `func(http.Handler) http.Handler`
|
|
|
|
- `http.Handler`
|
|
|
|
- `http.HandlerFunc`
|
|
|
|
- `func(http.ResponseWriter, *http.Request)`
|
|
|
|
- Extensible handler, supports:
|
|
|
|
- `echo.HandlerFunc`
|
|
|
|
- `func(*echo.Context) error`
|
|
|
|
- `http.Handler`
|
|
|
|
- `http.HandlerFunc`
|
|
|
|
- `func(http.ResponseWriter, *http.Request)`
|
2015-06-18 23:40:48 +02:00
|
|
|
- Sub-router/Groups
|
2015-07-08 22:51:08 +02:00
|
|
|
- Handy functions to send variety of HTTP response:
|
|
|
|
- HTML
|
|
|
|
- HTML via templates
|
2015-08-28 19:37:14 +02:00
|
|
|
- String
|
2015-07-11 21:20:59 +02:00
|
|
|
- JSON
|
2015-07-25 03:54:42 +02:00
|
|
|
- JSONP
|
2015-07-11 21:20:59 +02:00
|
|
|
- XML
|
2015-08-05 04:45:44 +02:00
|
|
|
- File
|
2015-07-08 22:51:08 +02:00
|
|
|
- NoContent
|
|
|
|
- Redirect
|
|
|
|
- Error
|
2015-06-03 18:20:32 +02:00
|
|
|
- Build-in support for:
|
2015-07-08 22:51:08 +02:00
|
|
|
- Favicon
|
|
|
|
- Index file
|
2015-06-18 23:40:48 +02:00
|
|
|
- Static files
|
|
|
|
- WebSocket
|
|
|
|
- Centralized HTTP error handling.
|
2015-07-08 22:51:08 +02:00
|
|
|
- Customizable HTTP request binding function.
|
|
|
|
- Customizable HTTP response rendering function, allowing you to use any HTML template engine.
|
2015-04-19 06:53:38 +02:00
|
|
|
|
2015-06-22 23:25:39 +02:00
|
|
|
## Performance
|
|
|
|
|
2015-06-27 23:34:22 +02:00
|
|
|
<iframe width="600" height="371" seamless frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/1phsG_NPmEOaTVTw6lasK3CeEwBlbkhzAWPiyrBznm1g/pubchart?oid=178095723&format=interactive"></iframe>
|
2015-06-22 23:25:39 +02:00
|
|
|
|
2016-01-30 21:31:19 +02:00
|
|
|
## Echo System
|
|
|
|
|
|
|
|
### Who's using Echo?
|
|
|
|
|
2016-02-02 01:10:50 +02:00
|
|
|
- [LabStack](https://labstack.com)
|
2016-01-30 21:31:19 +02:00
|
|
|
- [ShowChampions](https://showchampions.photoserve.co)
|
|
|
|
- [deferpanic](https://deferpanic.com)
|
|
|
|
- [Center for Open Science](https://cos.io)
|
|
|
|
- [SeeSaw Labs](http://www.seesawlabs.com)
|
|
|
|
- [Kyäni](http://www.kyani.net)
|
|
|
|
- [Carrot Creative](http://carrot.is)
|
|
|
|
- [EurekaMetrics](http://eurekametrics.com)
|
|
|
|
- [Coursella](https://www.coursella.com)
|
|
|
|
- [blue Vanilla](https://www.bleuvanille.fr)
|
|
|
|
- [ImPlaces](http://www.implaces.com)
|
|
|
|
- [Gomoku](http://gomoku.thoughtsfromplac.es)
|
|
|
|
- [DrinkIn](https://drinkin.com)
|
|
|
|
- [PodBaby](https://podbaby.me)
|
|
|
|
|
|
|
|
### Community created packages around Echo
|
|
|
|
|
|
|
|
- [echo-logrus](https://github.com/deoxxa/echo-logrus)
|
|
|
|
- [go_middleware](https://github.com/rightscale/go_middleware)
|
|
|
|
- [permissions2](https://github.com/xyproto/permissions2)
|
|
|
|
- [permissionbolt](https://github.com/xyproto/permissionbolt)
|
|
|
|
- [echo-middleware](https://github.com/syntaqx/echo-middleware)
|
|
|
|
- [dpecho](https://github.com/deferpanic/dpecho)
|
|
|
|
- [echosentry](https://github.com/01walid/echosentry)
|
|
|
|
- [go-starter-kit](https://github.com/olebedev/go-starter-kit)
|
|
|
|
|
|
|
|
[Want to get listed?](https://github.com/labstack/echo/issues/295)
|
|
|
|
|
2015-04-25 00:13:06 +02:00
|
|
|
## Getting Started
|
2015-04-19 06:53:38 +02:00
|
|
|
|
2015-04-25 00:13:06 +02:00
|
|
|
### Installation
|
|
|
|
|
2015-04-25 21:46:27 +02:00
|
|
|
```sh
|
|
|
|
$ go get github.com/labstack/echo
|
|
|
|
```
|
2015-04-19 06:53:38 +02:00
|
|
|
|
2015-07-02 06:22:51 +02:00
|
|
|
### Hello, World!
|
2015-04-20 07:47:58 +02:00
|
|
|
|
2015-07-08 22:51:08 +02:00
|
|
|
Create `server.go`
|
2015-04-19 06:53:38 +02:00
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/labstack/echo"
|
2015-04-21 08:24:34 +02:00
|
|
|
mw "github.com/labstack/echo/middleware"
|
2015-04-19 06:53:38 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Handler
|
2015-05-21 00:59:36 +02:00
|
|
|
func hello(c *echo.Context) error {
|
2015-05-06 06:55:49 +02:00
|
|
|
return c.String(http.StatusOK, "Hello, World!\n")
|
2015-04-19 06:53:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2015-04-25 21:46:27 +02:00
|
|
|
// Echo instance
|
2015-04-19 06:53:38 +02:00
|
|
|
e := echo.New()
|
|
|
|
|
|
|
|
// Middleware
|
2015-05-15 21:29:14 +02:00
|
|
|
e.Use(mw.Logger())
|
2015-05-18 20:33:11 +02:00
|
|
|
e.Use(mw.Recover())
|
2015-04-19 06:53:38 +02:00
|
|
|
|
|
|
|
// Routes
|
|
|
|
e.Get("/", hello)
|
|
|
|
|
|
|
|
// Start server
|
2015-05-10 17:22:49 +02:00
|
|
|
e.Run(":1323")
|
2015-04-19 06:53:38 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-07-08 22:51:08 +02:00
|
|
|
Start server
|
2015-04-19 06:53:38 +02:00
|
|
|
|
2015-04-25 21:46:27 +02:00
|
|
|
```sh
|
|
|
|
$ go run server.go
|
2015-04-19 06:53:38 +02:00
|
|
|
```
|
2015-04-19 07:27:30 +02:00
|
|
|
|
2015-05-10 17:22:49 +02:00
|
|
|
Browse to [http://localhost:1323](http://localhost:1323) and you should see
|
2015-04-25 21:46:27 +02:00
|
|
|
Hello, World! on the page.
|
|
|
|
|
2015-04-26 01:10:28 +02:00
|
|
|
### Next?
|
2015-06-30 21:10:35 +02:00
|
|
|
- Browse [recipes](https://github.com/labstack/echo/tree/master/recipes)
|
2015-10-08 22:54:31 +02:00
|
|
|
- Head over to [guide]({{< relref "guide/installation.md" >}})
|
2015-04-26 01:10:28 +02:00
|
|
|
|
2015-04-20 07:04:30 +02:00
|
|
|
## Contribute
|
2015-04-25 21:46:27 +02:00
|
|
|
|
|
|
|
**Use issues for everything**
|
2015-04-27 07:41:41 +02:00
|
|
|
|
2015-04-29 22:54:47 +02:00
|
|
|
- Report issues
|
2015-04-25 21:46:27 +02:00
|
|
|
- Discuss before sending pull request
|
2015-04-20 07:04:30 +02:00
|
|
|
- Suggest new features
|
2015-04-25 21:46:27 +02:00
|
|
|
- Improve/fix documentation
|
2015-04-20 07:04:30 +02:00
|
|
|
|
2015-04-26 01:10:28 +02:00
|
|
|
## Credits
|
|
|
|
- [Vishal Rana](https://github.com/vishr) - Author
|
|
|
|
- [Nitin Rana](https://github.com/nr17) - Consultant
|
|
|
|
- [Contributors](https://github.com/labstack/echo/graphs/contributors)
|
|
|
|
|
2015-04-19 07:27:30 +02:00
|
|
|
## License
|
|
|
|
|
|
|
|
[MIT](https://github.com/labstack/echo/blob/master/LICENSE)
|