Go HTTP framework with high-performance and strong-extensibility for building micro-services.
Go to file
Wenju Gao 0e582ecbbe
merge back: v0.9.3 (#1189)
#### What type of PR is this?
<!--
Add one of the following kinds:

build: Changes that affect the build system or external dependencies
(example scopes: gulp, broccoli, npm)
ci: Changes to our CI configuration files and scripts (example scopes:
Travis, Circle, BrowserStack, SauceLabs)
docs: Documentation only changes
feat: A new feature
optimize: A new optimization
fix: A bug fix
perf: A code change that improves performance
refactor: A code change that neither fixes a bug nor adds a feature
style: Changes that do not affect the meaning of the code (white space,
formatting, missing semi-colons, etc)
test: Adding missing tests or correcting existing tests
chore: Changes to the build process or auxiliary tools and libraries
such as documentation generation
-->

#### Check the PR title.
<!--
The description of the title will be attached in Release Notes, 
so please describe it from user-oriented, what this PR does / why we
need it.
Please check your PR title with the below requirements:
-->
- [ ] This PR title match the format: \<type\>(optional scope):
\<description\>
- [ ] The description of this PR title is user-oriented and clear enough
for others to understand.
- [ ] Attach the PR updating the user documentation if the current PR
requires user awareness at the usage level. [User docs
repo](https://github.com/cloudwego/cloudwego.github.io)


#### (Optional) Translate the PR title into Chinese.


#### (Optional) More detailed description for this PR(en: English/zh:
Chinese).
<!--
Provide more detailed info for review(e.g., it's recommended to provide
perf data if this is a perf type PR).
-->
en:
zh(optional):

#### (Optional) Which issue(s) this PR fixes:
<!--
Automatically closes linked issue when PR is merged.
Eg: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

#### (Optional) The PR that updates user documentation:
<!--
If the current PR requires user awareness at the usage level, please
submit a PR to update user docs. [User docs
repo](https://github.com/cloudwego/cloudwego.github.io)
-->
2024-09-06 14:15:14 +08:00
.github build: add Go 1.23 to unit tests CI (#1171) 2024-09-05 11:30:03 +08:00
cmd/hz feat: add flag to force update hertz_client.go (#1165) 2024-08-01 14:20:54 +08:00
examples feat: add auto-reloading for html render (#207) 2022-09-01 21:23:57 +08:00
images chore: update readme images and documentation (#1075) 2024-03-07 11:50:43 +08:00
internal feat: support partitioned cookies (#1041) 2024-01-12 11:03:58 +08:00
licenses optimize(hz): use sprig to add template function (#784) 2023-09-01 17:21:53 +08:00
pkg fix: update ut for assert.NotNil (#1181) 2024-09-02 15:45:58 +08:00
script Initial commit 2022-05-31 15:34:58 +08:00
_typos.toml chore: update go mod and CI to support go1.22 (#1158) 2024-07-29 17:34:15 +08:00
.codecov.yml chore: support codecov (#186) 2022-08-12 10:37:49 +08:00
.gitattributes chore: add .gitattributes to standardize the default end-of-file line (#981) 2023-11-06 14:59:42 +08:00
.gitignore build: add Go 1.23 to unit tests CI (#1171) 2024-09-05 11:30:03 +08:00
.golangci.yaml test: fix netpoll ut in windows (#536) 2023-01-31 09:59:08 +08:00
.licenserc.yaml refactor: open hz code for being called 2022-11-18 11:50:27 +08:00
CODE_OF_CONDUCT.md Initial commit 2022-05-31 15:34:58 +08:00
CONTRIBUTING.md Initial commit 2022-05-31 15:34:58 +08:00
go.mod build: add Go 1.23 to unit tests CI (#1171) 2024-09-05 11:30:03 +08:00
go.sum build: add Go 1.23 to unit tests CI (#1171) 2024-09-05 11:30:03 +08:00
LICENSE Initial commit 2022-05-31 15:34:58 +08:00
Makefile Initial commit 2022-05-31 15:34:58 +08:00
NOTICE Initial commit 2022-05-31 15:34:58 +08:00
README_cn.md chore: update readme images and documentation (#1075) 2024-03-07 11:50:43 +08:00
README.md chore: update readme images and documentation (#1075) 2024-03-07 11:50:43 +08:00
ROADMAP.md Update ROADMAP.md (#998) 2023-11-15 20:35:25 +08:00
version.go chore: update version v0.9.3 2024-09-06 10:55:36 +08:00

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 designed with reference to other open-source frameworks like fasthttp, 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, HTTP/2, HTTP/3, 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, monitoring, OpenTelemetry integration. more

Service Governance

Contains service registration and discovery extensions, Sentinel integration. more

Framework Extension

Contains network library extensions. more

Reference

Apidoc, 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.

  • Netpoll: A high-performance network library. Hertz integrated by default.
  • Hertz-contrib: A partial extension library of Hertz, which users can integrate into Hertz through options according to their needs.
  • Example: Use examples of Hertz.

Extensions

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 with multi-backend support

Blogs

Contributing

Contributing

RoadMap

Hertz RoadMap

License

Hertz is distributed under the Apache License, version 2.0. The licenses of third party dependencies of Hertz are explained here.

Community

LarkGroup

Contributors

Thank you for your contribution to Hertz!

Contributors

Landscapes

  

CloudWeGo enriches the CNCF CLOUD NATIVE Landscape.