百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

hertz-examples

> 编程语言
开源

赫兹的示例

348 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

赫兹的示例

Hertz Examples

English | 中文

How to run

Enter an example directory for its specific run instructions. Unless an example says otherwise, run commands from the repository root.

Bizdemo

  • bizdemo/hertz_gorm: Use Thrift IDL, hz, Hertz binding and validation, GORM, and MySQL in a Hertz service.
  • bizdemo/hertz_jwt: Build a Hertz service with JWT authentication, GORM, and MySQL.
  • bizdemo/hertz_session: Use Redis-backed distributed sessions and CSRF protection in a Hertz service.
  • bizdemo/hertz_swagger_gen: Generate Swagger documentation and a Swagger UI service from Thrift IDL with thrift-gen-http-swagger.
  • bizdemo/tiktok_demo: A simple Hertz backend for user, video, social, feed, favorite, comment, and message services.
  • formulago: An enterprise administration framework built with Hertz and Ent.
  • gpress: A Web3 content platform built with Hertz and Go templates, with FTS5 full-text search and Hugo compatibility.

Server

  • hello: A basic Hertz “hello world” server.
  • config: Configure a Hertz server.
  • protocol: Use HTTP/1.1 and TLS with Hertz. It also links to external protocol examples.
    • HTTP1: A Hertz HTTP/1.1 server.
    • TLS: A TLS server plus a Hertz client that sends a TLS request.
    • HTTP2: The external Hertz HTTP/2 examples.
    • HTTP3: The external Hertz HTTP/3 example based on QUIC.
    • WebSocket: The external Hertz WebSocket examples.
    • SSE: A Hertz Server-Sent Events server and client using Hertz’s built-in SSE package.
  • middleware: Server middleware examples, including BasicAuth, CORS, CSRF, custom middleware, pprof, RequestID, Gzip, and load balancing.
    • basicauth: Use BasicAuth middleware.
    • CORS: Use CORS middleware.
    • csrf: Configure CSRF middleware, including custom token extraction and skip rules.
    • custom: Write and register custom middleware.
    • pprof: Configure pprof middleware.
    • requestid: Configure RequestID middleware and custom ID handling.
    • gzip: Configure Gzip compression and route/path exclusions.
    • loadbalance: Configure a non-default load-balancing algorithm.
    • Recovery: Use the built-in Recovery middleware.
    • JWT: Use JWT authentication middleware.
    • i18n: Use internationalization middleware.
    • session: Use session middleware with cookie or Redis backends.
    • KeyAuth: Authenticate requests with a configurable key lookup.
    • Swagger: Serve Swagger documentation with Hertz.
    • access log: Log HTTP access details.
    • Secure: Configure security-related HTTP headers and redirects.
    • Sentry: Report Hertz request errors to Sentry.
    • Casbin: Apply Casbin authorization middleware.
    • ETag: Add ETag response headers and customize ETag behavior.
    • Cache: Cache Hertz responses with memory or Redis backends.
    • Paseto: Protect routes with PASETO tokens.
  • binding: Bind request parameters and validate them.
  • parameters: Read query, form, and cookie parameters.
  • file: Upload and download files, serve static files, and render HTML from files or templates.
  • render: Render JSON, HTML, Protobuf, text, XML, and customized YAML responses.
  • redirect: Redirect requests to internal or external URIs.
  • route: Register static, grouped, parameterized, and middleware-protected routes, and inspect route metadata.
  • streaming: Stream request and response bodies from a Hertz server.
  • graceful_shutdown: Gracefully shut down a Hertz server.
  • unit_test: Test Hertz handlers with ResponseRecord and PerformRequest without network transmission.
  • monitoring: Export Hertz and Go runtime metrics to Prometheus and visualize them in Grafana.
  • opentelemetry: Trace a Hertz-to-Kitex request, export telemetry through OpenTelemetry Collector, and view traces and metrics in Jaeger and Grafana/VictoriaMetrics.
  • multiple_service: Run multiple Hertz services on different ports.
  • adaptor: Adapt standard-library http.Handler implementations for use in Hertz, including a Jade template example.
  • sentinel: Use Sentinel for traffic control with Hertz.
  • reverseproxy: Use the Hertz reverse proxy extension, with examples for standard proxying, TLS, discovery, response modification, SSE, middleware, and WebSocket.
  • hlog: Use Hertz logging and its logger extensions.
  • trailer: Read and write HTTP trailers with Hertz.
  • graphql-go: Serve GraphQL requests from a Hertz server.

Client

  • client/send_request: Send requests with the Hertz client, including deadlines, redirects, and timeouts.
  • client/config: Configure a Hertz client.
  • protocol/tls: Send a TLS request with the Hertz client to the example TLS server.
  • client/add_parameters: Add query, form, path, and body parameters to Hertz client requests.
  • client/upload_file: Upload files with the Hertz client.
  • client/middleware: Use client middleware.
  • client/streaming_read: Read a streaming response with the Hertz client.
  • client/forward_proxy: Configure a forward proxy for the Hertz client.
  • trailer: Send a request and read its HTTP trailer with the Hertz client.

Hz

  • hz/thrift: Use hz with Thrift IDL to generate server code.
  • hz/protobuf: Use hz with Protobuf IDL to generate server code.
  • hz/hz_client: Use hz to generate client code.
  • hz/template: Use a custom hz template to generate a server project.
  • hz/plugin: Use third-party hz code-generation plugins with Thrift and Protobuf projects.
  • hz/struct_reuse: Reuse Kitex-generated Thrift structs as Hertz models.

Note

Commands for an example should be run from the hertz-examples repository root unless that example’s own README says otherwise.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goexamplehertzhttp

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言