mirror of
https://github.com/labstack/echo.git
synced 2024-12-22 20:06:21 +02:00
0176385654
Signed-off-by: Vishal Rana <vr@labstack.com>
2.5 KiB
2.5 KiB
title |
---|
Index |
Echo
A fast and unfancy micro web framework for Go.
Features
- Fast HTTP router which smartly prioritize routes.
- 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)
- Sub-router/Groups
- Handy functions to send variety of HTTP response:
- HTML
- HTML via templates
- String
- JSON
- JSONP
- XML
- File
- NoContent
- Redirect
- Error
- Build-in support for:
- Favicon
- Index file
- Static files
- WebSocket
- Centralized HTTP error handling.
- Customizable HTTP request binding function.
- Customizable HTTP response rendering function, allowing you to use any HTML template engine.
Performance
Getting Started
Installation
$ go get github.com/labstack/echo
Hello, World!
Create server.go
package main
import (
"net/http"
"github.com/labstack/echo"
mw "github.com/labstack/echo/middleware"
)
// Handler
func hello(c *echo.Context) error {
return c.String(http.StatusOK, "Hello, World!\n")
}
func main() {
// Echo instance
e := echo.New()
// Middleware
e.Use(mw.Logger())
e.Use(mw.Recover())
// Routes
e.Get("/", hello)
// Start server
e.Run(":1323")
}
Start server
$ go run server.go
Browse to http://localhost:1323 and you should see Hello, World! on the page.
Next?
- Browse recipes
- Head over to [guide]({{< relref "guide/installation.md" >}})
Contribute
Use issues for everything
- Report issues
- Discuss before sending pull request
- Suggest new features
- Improve/fix documentation
Credits
- Vishal Rana - Author
- Nitin Rana - Consultant
- Contributors