echo README

项目的 README,来自 github.com/labstack/echo。合并为一个 markdown 文件:README.md。

Echo

High performance, extensible, minimalist Go web framework.

Latest release Last commit Go Reference CI Codecov OpenSSF Scorecard Sponsors Discussions X License

Website · Quick start · Middleware · API reference · Discussions · Echo Pro · Commercial support

About

Echo is built on Go's standard net/http and interoperates with it through echo.WrapHandler and echo.WrapMiddleware. It adds the parts the standard library leaves to you: a fast radix-tree router, request binding with pluggable validation, official and third-party middleware, and centralized error handling. Echo is actively maintained, and v5 is the current release line.

How a request flows

  1. Pre middleware (e.Pre) runs before routing, so it can rewrite the path or method.
  2. The router matches the route.
  3. Middleware registered with e.Use, a group or a route runs.
  4. The handler writes the response.
  5. Any error returned by middleware or the handler goes to one HTTPErrorHandler.

Features

Echo Pro and support

Echo Pro is a separate commercial library from LabStack for Echo v5: API key and JWT authentication, tenant isolation, quotas with usage metering, audit records, signed webhooks and an admin console. Echo itself stays MIT, and Pro subscriptions fund its maintenance.

Echo Support is a paid annual plan for v4 and v5 applications, with a named contact and email support.

Used by

Echo runs in production across the Go ecosystem, including:

Project What runs on Echo
Bluesky indigo AT Protocol Relay and network services
Temporal UI Temporal Web UI server
NVIDIA Cloud Functions LLM API gateway
Azure Container Networking Container Networking Service REST API
osbuild-composer Red Hat Image Builder cloud API
Docker Agent Agent API, chat and A2A servers
YugabyteDB yugabyted UI API server
PostHog Livestream service
Bytebase Backend server and API
Hatchet API server
CasaOS API server
Hanko Authentication backend

See ADOPTERS.md for the full list. Using Echo in an open source project? Add it.

Sponsors

Sponsor
Blacksmith logo Blacksmith: faster, drop-in GitHub Actions runners
Encore logo Encore: the platform for building Go-based cloud backends
Gravity Carbon logo Gravity Carbon

Echo is independent and community funded. If your company depends on Echo, please consider sponsoring it.

Getting started

Supported versions

Note: Echo v4 is in maintenance and gets no new features. Start new projects on v5, and plan v4 upgrades with API_CHANGES_V5.md.

See ROADMAP.md for where Echo is heading and the version support policy.

Installation

go get github.com/labstack/echo/v5

Echo v5 supports the three most recent Go releases and may work with older ones. Echo v4 requires Go 1.26 or later.

Example

package main

import (
	"log/slog"
	"net/http"

	"github.com/labstack/echo/v5"
	"github.com/labstack/echo/v5/middleware"
)

func main() {
	e := echo.New()

	e.Use(middleware.RequestLogger()) // log requests with log/slog
	e.Use(middleware.Recover())       // recover from panics and return an error

	e.GET("/", hello)

	if err := e.Start(":8080"); err != nil {
		slog.Error("failed to start server", "error", err)
	}
}

func hello(c *echo.Context) error {
	return c.String(http.StatusOK, "Hello, World!")
}

Run it and send a request:

$ go run .
$ curl http://localhost:8080/
Hello, World!

e.Start shuts the server down gracefully on Ctrl+C.

More in the guide and the cookbook.

Middleware

Official

Maintained by the Echo team.

Repository Description
labstack/echo-jwt JWT authentication
labstack/echo-contrib Casbin, gorilla/sessions and pprof
labstack/echo-otel OpenTelemetry tracing and metrics
labstack/echo-prometheus Prometheus metrics

Third-party

Third-party middleware list

These projects are maintained by their authors, not the Echo team. Review them before use, and check which Echo version (v4 or v5) each supports.

Repository Description
oapi-codegen/oapi-codegen OpenAPI client and server code generator
swaggo/echo-swagger Serves Swagger 2.0 API documentation
ziflex/lecho Zerolog logger for Echo
brpaz/echozap Uber Zap logging middleware
samber/slog-echo log/slog logging middleware
darkweak/souin HTTP cache middleware based on Souin, with distributed storage support
mikestefanello/pagoda Full-stack web development starter kit built on Echo
go-woo/protoc-gen-echo Generates Echo server code from Protocol Buffers

To add your library, send a pull request.

Contributing

Security

Important: Report vulnerabilities privately through GitHub Security Advisories, not in public issues. See SECURITY.md for supported versions.

Credits

License

MIT

echo (labstack/echo)

正在搜索数据库…

32.8K ·GitHub
这是什么?Echo 是一个高性能、极简的 Go Web 框架,用于构建 Web 应用、RESTful API 和微服务。
它是框架还是库?和 Go 标准库的 net/http 怎么配合?它是一个构建在 Go 标准 net/http 之上的框架,并且能与 net/http 互操作——已有的处理器和中间件可以通过 echo.WrapHandler 和 echo.WrapMiddleware 直接接入。
怎么把它加到我的项目里?像添加其他 Go 依赖一样,用 go get 把 Echo 模块加进项目,然后按照官网上的快速上手指南操作即可——不需要安装别的东西。
它支持哪些 Go 版本?最新的 Echo 版本支持最近四个 Go 大版本,更旧的版本也许也能用。
我该从 v4 还是 v5 入手?从 v5 开始——截至 2026 年 1 月,它是当前的主线版本。v4 在 2026 年 12 月 31 日之前只获得安全更新和缺陷修复,v4 到 v5 的 API 变更都列在 APICHANGESV5.md 里。
可以用在商业项目里吗?可以——Echo 采用 MIT 许可证,商业使用、修改和再分发都没问题。
它能帮我处理 HTTPS 和 HTTP/2 吗?可以。Echo 支持通过 Let's Encrypt 自动获取 TLS 证书,并且内置 HTTP/2 支持,所以不需要额外架一个代理来提供安全流量。
有没有现成的全栈应用起步套件?有——README 里列出的第三方项目 Pagoda,是一个基于 Echo 构建的快速、易用的全栈 Web 开发起步套件。
能从我的代码生成 API 文档吗?可以通过第三方中间件实现:oapi-codegen 可以生成 OpenAPI 的客户端和服务器代码,swaggo/echo-swagger 可以为 REST API 生成 Swagger 2.0 文档。
这个项目成熟吗?非常成熟——从 2015 年 3 月开始开发,在 GitHub 上有超过 32000 颗星,目前以 v5 作为当前发布主线持续积极维护,并获得了 Encore 等平台的赞助。
有哪些类似的项目?actix-web, iris, fiber, Slim, go-zero, chi, gofr, hono
作者
labstack
大小
6.8 MB
星标
32.8K
时长
11年
提交 · 90 天