2015-10-02 03:24:38 +02:00
|
|
|
---
|
|
|
|
title: Index
|
|
|
|
---
|
|
|
|
|
2016-03-06 06:03:11 +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.
|
2016-03-11 07:40:25 +02: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 23:40:48 +02:00
|
|
|
- Centralized HTTP error handling.
|
2016-03-11 07:40:25 +02:00
|
|
|
- Template rendering with any 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
|
|
|
|
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
|
|
|
|
2016-03-11 07:40:25 +02:00
|
|
|
Create `main.go`
|
2015-04-19 06:53:38 +02:00
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/labstack/echo"
|
2016-03-11 07:40:25 +02:00
|
|
|
"github.com/labstack/echo/engine/standard"
|
|
|
|
"github.com/labstack/echo/middleware"
|
2015-04-19 06:53:38 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Handler
|
2016-03-11 07:40:25 +02:00
|
|
|
func hello() echo.HandlerFunc {
|
|
|
|
return func(c echo.Context) error {
|
|
|
|
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
|
2016-03-11 07:40:25 +02:00
|
|
|
e.Use(middleware.Logger())
|
|
|
|
e.Use(middleware.Recover())
|
2015-04-19 06:53:38 +02:00
|
|
|
|
|
|
|
// Routes
|
2016-03-11 07:40:25 +02:00
|
|
|
e.Get("/", hello())
|
2015-04-19 06:53:38 +02:00
|
|
|
|
|
|
|
// Start server
|
2016-03-11 07:40:25 +02:00
|
|
|
e.Run(standard.New(":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
|
2016-03-11 07:40:25 +02:00
|
|
|
$ go run main.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?
|
2016-03-11 07:40:25 +02:00
|
|
|
- Browse [recipes](/recipes/hello-world)
|
|
|
|
- Head over to [guide](/guide/installation")
|
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)
|