MCPcopy
hub / github.com/cloudwego/hertz

github.com/cloudwego/hertz @v0.10.5 sqlite

repository ↗ · DeepWiki ↗ · release v0.10.5 ↗
4,503 symbols 23,919 edges 375 files 1,346 documented · 30%
README

Hertz

English | 中文

Release WebSite License Go Report Card OpenIssue ClosedIssue Stars Forks

Hertz [həːts] is a high-usability, high-performance and high-extensibility Golang HTTP framework that helps developers build microservices. It was originally a fork of fasthttp and inspired by gin, echo and combined with the internal requirements in ByteDance. At present, it has been widely used inside ByteDance. Nowadays, more and more microservices use Golang. If you have requirements for microservice performance and hope that the framework can fully meet the internal customizable requirements, Hertz will be a good choice.

Basic Features

  • High usability

During the development process, it is often more important to write the correct code quickly. Therefore, in the iterative process of Hertz, we actively listen to users' opinions and continue to polish the framework, hoping to provide users with a better user experience and help users write correct code faster. - High performance

Hertz uses the self-developed high-performance network library Netpoll by default. In some special scenarios, compared to Go Net, Hertz has certain advantages in QPS and time delay. For performance data, please refer to the Echo data in the figure below.

Comparison of four frameworks: Performance Comparison of three frameworks: Performance For detailed performance data, please refer to hertz-benchmark. - High extensibility

Hertz adopts a layered design, providing more interfaces and default extension implementations. Users can also extend by themselves. At the same time, thanks to the layered design of the framework, the extensibility of the framework will be much greater. At present, only stable capabilities are open-sourced to the community. More planning refers to RoadMap. - Multi-protocol support

The Hertz framework provides HTTP/1.1 and ALPN protocol support natively. In addition, due to the layered design, Hertz even supports custom build protocol resolution logic to meet any needs of protocol layer extensions. - Network layer switching capability

Hertz implements the function to switch between Netpoll and Go Net on demand. Users can choose the appropriate network library for different scenarios. And Hertz also supports the extension of network library in the form of plug-ins.

Documentation

Getting Started

Example

The Hertz-Examples repository provides code out of the box. more

Basic Features

Contains introduction and use of general middleware, context selection, data binding, data rendering, direct access, logging, error handling. more

Observability

Contains instrumentation, logging, tracing. more

Framework Extension

Contains network library extensions, protocol extensions, logger extensions, monitoring extensions. more

Reference

Framework configurable items list. more

FAQ

Frequently Asked Questions. more

Performance

Performance testing can only provide a relative reference. In production, there are many factors that can affect actual performance. We provide the hertz-benchmark project to track and compare the performance of Hertz and other frameworks in different situations for reference.

Related Projects

  • Netpoll: A high-performance network library. Hertz integrated by default.
  • Example: Use examples of Hertz.

Extensions

Hertz-contrib is a partial extension library of Hertz, which users can integrate into Hertz through options according to their needs, built and maintained by the community.

Extensions Description
Autotls Make Hertz support Let's Encrypt.
Http2 HTTP2 support for Hertz.
Websocket Enable Hertz to support the Websocket protocol.
Etag Support ETag (or entity tag) HTTP response header for Hertz.
Limiter Provides a current limiter based on the bbr algorithm.
Monitor-prometheus Provides service monitoring based on Prometheus.
Obs-opentelemetry Hertz's Opentelemetry extension that supports Metric, Logger, Tracing and works out of the box.
Opensergo The Opensergo extension.
Pprof Extension for Hertz integration with Pprof.
Registry Provides service registry and discovery functions. So far, the supported service discovery extensions are nacos, consul, etcd, eureka, polaris, servicecomb, zookeeper, redis.
Sentry Sentry extension provides some unified interfaces to help users perform real-time error monitoring.
Tracer Link tracing based on Opentracing.
Basicauth Basicauth middleware can provide HTTP basic authentication.
Jwt Jwt extension.
Keyauth Provides token-based authentication.
Requestid Add request id in response.
Sessions Session middleware with multi-state store support.
Casbin Supports various access control models by Casbin.
Cors Provides cross-domain resource sharing support.
Csrf Csrf middleware is used to prevent cross-site request forgery attacks.
Secure Secure middleware with multiple configuration items.
Gzip A Gzip extension with multiple options.
I18n Helps translate Hertz programs into multi programming languages.
Lark Use hertz handle Lark/Feishu card message and event callback.
Loadbalance Provides load balancing algorithms for Hertz.
Logger Logger extension for Hertz, which provides support for zap, logrus, zerologs logging frameworks.
Recovery Recovery middleware for Hertz.
Reverseproxy Implement a reverse proxy.
Swagger Automatically generate RESTful API documentation with Swagger 2.0.
Cache Hertz middleware for cache HTTP response wi

Extension points exported contracts — how you extend this code

Reader (Interface)
Reader is for buffered Reader [7 implementers]
pkg/network/connection.go
Render (Interface)
Render interface is to be implemented by JSON, XML, HTML, YAML and so on. [8 implementers]
pkg/app/server/render/render.go
Literal (Interface)
(no doc) [9 implementers]
cmd/hz/generator/model/model.go
Server (Interface)
(no doc) [4 implementers]
pkg/protocol/server.go
ListenerIface (Interface)
double check listener [2 implementers]
pkg/route/engine.go
Tracer (Interface)
Tracer is executed at the start and finish of an HTTP. [2 implementers]
pkg/common/tracer/tracer.go
RouteEngine (Interface)
(no doc) [3 implementers]
internal/testutils/testutils.go
ExprNode (Interface)
ExprNode expression interface
internal/tagexpr/expr.go

Core symbols most depended-on inside this repo

DeepEqual
called by 1721
pkg/common/test/assert/assert.go
Fatalf
called by 789
pkg/common/hlog/log.go
Nil
called by 299
pkg/common/test/assert/assert.go
Error
called by 299
pkg/common/hlog/log.go
Errorf
called by 294
pkg/common/hlog/log.go
Errorf
called by 252
cmd/hz/util/logs/api.go
String
called by 211
internal/tagexpr/expr.go
Assert
called by 197
pkg/common/test/assert/assert.go

Shape

Function 2,041
Method 1,842
Struct 465
Interface 70
TypeAlias 59
FuncType 26

Languages

Go100%

Modules by API surface

pkg/app/context.go171 symbols
pkg/protocol/header.go164 symbols
pkg/app/context_test.go112 symbols
pkg/app/server/binding/binder_test.go101 symbols
pkg/route/engine_test.go90 symbols
pkg/protocol/request.go86 symbols
pkg/route/engine.go76 symbols
pkg/common/test/mock/network.go76 symbols
pkg/protocol/http1/client.go60 symbols
pkg/app/client/client_test.go58 symbols
pkg/route/routes_test.go57 symbols
pkg/protocol/http1/req/request_test.go57 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

github.com/Masterminds/sprig/v3v3.2.3 · 1×
github.com/bytedance/gopkgv0.1.4 · 1×
github.com/bytedance/sonicv1.15.0 · 1×
github.com/bytedance/sonic/loaderv0.5.0 · 1×
github.com/cloudwego/base64xv0.1.6 · 1×
github.com/cloudwego/gopkgv0.2.0 · 1×
github.com/cloudwego/netpollv0.7.3 · 1×
github.com/cloudwego/thriftgov0.4.2-0.20250604064 · 1×
github.com/davecgh/go-spewv1.1.2-0.20180830191 · 1×
github.com/fsnotify/fsnotifyv1.5.4 · 1×
github.com/jhump/protoreflectv1.12.0 · 1×

For agents

$ claude mcp add hertz \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact