2015-10-01 18:24:38 -07:00
|
|
|
---
|
|
|
|
title: Index
|
|
|
|
---
|
|
|
|
|
2016-03-05 20:03:11 -08:00
|
|
|
# ![Echo](/images/echo.svg) Echo
|
2015-04-19 22:04:30 -07:00
|
|
|
|
2015-10-01 18:24:38 -07:00
|
|
|
A fast and unfancy micro web framework for Go.
|
2015-04-19 22:04:30 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
|
2015-04-18 21:53:38 -07:00
|
|
|
## Features
|
|
|
|
|
2015-06-18 14:40:48 -07:00
|
|
|
- Fast HTTP router which smartly prioritize routes.
|
2016-03-10 21:40:25 -08:00
|
|
|
- Run with standard HTTP server or FastHTTP server.
|
|
|
|
- Extensible middleware framework.
|
|
|
|
- Router groups with nesting.
|
|
|
|
- Handy functions to send variety of HTTP responses.
|
2015-06-18 14:40:48 -07:00
|
|
|
- Centralized HTTP error handling.
|
2016-03-10 21:40:25 -08:00
|
|
|
- Template rendering with any template engine.
|
2015-04-18 21:53:38 -07:00
|
|
|
|
2015-06-22 14:25:39 -07: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 14:25:39 -07:00
|
|
|
|
2015-04-24 15:13:06 -07:00
|
|
|
## Getting Started
|
2015-04-18 21:53:38 -07:00
|
|
|
|
2015-04-24 15:13:06 -07:00
|
|
|
### Installation
|
|
|
|
|
2015-04-25 12:46:27 -07:00
|
|
|
```sh
|
|
|
|
$ go get github.com/labstack/echo
|
|
|
|
```
|
2015-04-18 21:53:38 -07:00
|
|
|
|
2015-07-01 21:22:51 -07:00
|
|
|
### Hello, World!
|
2015-04-19 22:47:58 -07:00
|
|
|
|
2016-03-10 21:40:25 -08:00
|
|
|
Create `main.go`
|
2015-04-18 21:53:38 -07:00
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/labstack/echo"
|
2016-03-10 21:40:25 -08:00
|
|
|
"github.com/labstack/echo/engine/standard"
|
|
|
|
"github.com/labstack/echo/middleware"
|
2015-04-18 21:53:38 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// Handler
|
2016-03-10 21:40:25 -08:00
|
|
|
func hello() echo.HandlerFunc {
|
|
|
|
return func(c echo.Context) error {
|
|
|
|
return c.String(http.StatusOK, "Hello, World!\n")
|
|
|
|
}
|
2015-04-18 21:53:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2015-04-25 12:46:27 -07:00
|
|
|
// Echo instance
|
2015-04-18 21:53:38 -07:00
|
|
|
e := echo.New()
|
|
|
|
|
|
|
|
// Middleware
|
2016-03-10 21:40:25 -08:00
|
|
|
e.Use(middleware.Logger())
|
|
|
|
e.Use(middleware.Recover())
|
2015-04-18 21:53:38 -07:00
|
|
|
|
|
|
|
// Routes
|
2016-03-10 21:40:25 -08:00
|
|
|
e.Get("/", hello())
|
2015-04-18 21:53:38 -07:00
|
|
|
|
|
|
|
// Start server
|
2016-03-10 21:40:25 -08:00
|
|
|
e.Run(standard.New(":1323"))
|
2015-04-18 21:53:38 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-07-08 13:51:08 -07:00
|
|
|
Start server
|
2015-04-18 21:53:38 -07:00
|
|
|
|
2015-04-25 12:46:27 -07:00
|
|
|
```sh
|
2016-03-10 21:40:25 -08:00
|
|
|
$ go run main.go
|
2015-04-18 21:53:38 -07:00
|
|
|
```
|
2015-04-18 22:27:30 -07:00
|
|
|
|
2015-05-10 08:22:49 -07:00
|
|
|
Browse to [http://localhost:1323](http://localhost:1323) and you should see
|
2015-04-25 12:46:27 -07:00
|
|
|
Hello, World! on the page.
|
|
|
|
|
2015-04-25 16:10:28 -07:00
|
|
|
### Next?
|
2016-03-10 21:40:25 -08:00
|
|
|
- Browse [recipes](/recipes/hello-world)
|
2016-03-12 03:54:54 -08:00
|
|
|
- Head over to [guide](/guide/installation)
|
2015-04-25 16:10:28 -07:00
|
|
|
|
2015-04-19 22:04:30 -07:00
|
|
|
## Contribute
|
2015-04-25 12:46:27 -07:00
|
|
|
|
|
|
|
**Use issues for everything**
|
2015-04-26 22:41:41 -07:00
|
|
|
|
2015-04-29 13:54:47 -07:00
|
|
|
- Report issues
|
2015-04-25 12:46:27 -07:00
|
|
|
- Discuss before sending pull request
|
2015-04-19 22:04:30 -07:00
|
|
|
- Suggest new features
|
2015-04-25 12:46:27 -07:00
|
|
|
- Improve/fix documentation
|
2015-04-19 22:04:30 -07:00
|
|
|
|
2015-04-25 16:10:28 -07: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-18 22:27:30 -07:00
|
|
|
## License
|
|
|
|
|
|
|
|
[MIT](https://github.com/labstack/echo/blob/master/LICENSE)
|