Skip to content
Proyectos

Acerca de

Examples for Hertz.

Herramientas de desarrollo

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
Recopilando historial
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

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

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.

Explorar proyectos relacionados

Cargando…