1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-22 20:06:21 +02:00
echo/website/content/index.md
2016-02-01 15:10:50 -08:00

3.7 KiB

title
Index

Echo 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

Echo System

Who's using Echo?

Community created packages around Echo

Want to get listed?

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

License

MIT