Ir al contenido

Echo

Echo v5.4.0 — release documentation

Build fast Go APIs.
Without the bloat.

A high-performance, minimalist Go web framework — a zero-allocation router, batteries-included middleware, and an expressive API. Ship production services in minutes.

go get github.com/labstack/echo/v5
server.go · excerpt
e := echo.New()
// Middleware
e.Use(middleware.RequestLogger())
e.Use(middleware.Recover())
// Route => handler
e.GET("/", func(c *echo.Context) error {
return c.String(http.StatusOK, "Hello, World!\n")
})
32.7kGitHub stars
0 allocsrouter, per request
25+built-in middlewares
MITopen source license
Why Echo

Everything you need. Nothing you don’t.

Optimized Router

Radix-tree routing with zero dynamic allocation and smart route prioritization.

Batteries-included Middleware

CORS, JWT, rate-limit, gzip, recover, request logging — 25+ built in.

Data Binding

Bind JSON, XML, form, query & path params into typed structs, with validation.

Automatic TLS

HTTPS out of the box via Let’s Encrypt, plus HTTP/2 support.

Extensible

Composable middleware and a clean, minimal interface for total control.

Templates

Plug in any Go template engine for fast, flexible HTML rendering.
Get Started

A running server in three steps.

  1. Install

    Create a module and add Echo.

    go mod init myapp
    go get github.com/labstack/echo/v5
  2. Write

    Save the Hello World server as server.go.

    package main
    import (
    "context"
    "net/http"
    "github.com/labstack/echo/v5"
    "github.com/labstack/echo/v5/middleware"
    )
    func main() {
    // Echo instance
    e := echo.New()
    // Middleware
    e.Use(middleware.RequestLogger())
    e.Use(middleware.Recover())
    // Route => handler
    e.GET("/", func(c *echo.Context) error {
    return c.String(http.StatusOK, "Hello, World!\n")
    })
    // Start server
    sc := echo.StartConfig{Address: ":1323"}
    if err := sc.Start(context.Background(), e); err != nil {
    e.Logger.Error("failed to start server", "error", err)
    }
    }
  3. Run

    Fetch dependencies and start serving on port 1323.

    go mod tidy
    go run server.go
Ecosystem

Official packages, ready to plug in.

Sponsors

Backed by teams who build on Echo.

BlacksmithBlacksmithFaster, drop-in GitHub Actions runners. EncoreEncoreThe platform for building Go-based cloud backends.

Site links

echo

High performance, extensible, minimalist Go web framework.