hertz-examples

module
v0.0.0-...-dcee47a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: Apache-2.0

README

Hertz Examples

English | 中文

How to run

You can enter the example for information about "How to run"

Bizdemo

Server

  • hello: Example of launching a hertz "hello world" application
  • config: Example of configuring hertz server
  • protocol: Example of using http1, tls and other protocols of hertz
    • HTTP1 Example of hertz using HTTP1 protocol
    • TLS Example of hertz using TLS protocol
    • HTTP2 Example of hertz using HTTP2 protocol
    • HTTP3 Example of hertz using HTTP3 protocol
    • Websocket Example of hertz using Websocket protocol
    • SSE Example of hertz using SSE protocol
  • middleware: Example of using middleware of hertz
    • basicauth: Example of using BasicAuth middleware
    • cors: Example of using CORS middleware
    • csrf: Example of using csrf middleware
    • custom: Example of using custom middleware
    • pprof: Example of using pprof middleware
    • requestid: Example of using RequestID middleware
    • gzip: Example of using Gzip middleware
    • loadbalance: Example of using Loadbalance middleware
    • Recovery Example of using Recovery middleware
    • jwt Example of using jwt middleware
    • i18n Example of using i18n middleware
    • session Example of using session middleware
    • KeyAuth Example of using KeyAuth middleware
    • Swagger Example of using Swagger middleware
    • access log Example of using access log middleware
    • Secure Example of using Secure middleware
    • Sentry Example of using Sentry middleware
    • Casbin Example of using Casbin middleware
    • ETag Example of using ETag middleware
    • Cache Example of using Cache middleware
    • Paseto Example of using Paseto middleware
  • binding: Example of parameter binding and validation
  • parameters: Example of getting query, form, cookie
  • file: Examples of file upload, file download, and static file services
  • render: Example of render body as json, html, protobuf
  • redirect: Examples of redirects to internal/external URI
  • streaming: Example of streaming read/write for hertz server
  • graceful_shutdown: Example of a graceful shutdown for hertz server
  • unit_test: Example of writing unit tests using the interface provided by hertz without network transmission
  • tracer: Example of using Jaeger for link tracing
  • monitoring: Example of using Prometheus for metrics monitoring
  • multiple_service: Example of using hertz with multiple services
  • adaptor: Example of using adaptor to integrate hertz with package built for http.Handler interface , including a demonstration on using jade as template engine.
  • sentinel: Example of using sentinel-golang in hertz
  • reverseproxy: Example of using reverseproxy in hertz server
  • gzip: Example of using gzip middleware in hertz server
  • hlog: Example of using hlog and its log extension
  • trailer: Example of read/write trailers for hertz server
  • graphql-go: Example of using graphql in hertz server

Client

Hz

  • hz/thrift: Example of using hz with thrift to generate server code
  • hz/protobuf: Example of using hz with protobuf to generate server code
  • hz/hz_client: Example of using hz to generate client code
  • hz/template: Example of using hz custom templates to generate server code
  • hz/plugin: Example of using hz to access third-party plugins
  • hz/struct_reuse: Example of using hz to use kitex_gen as hertz model

Note

All commands to execute the example should be executed under "hertz-example".

Directories

Path Synopsis
jade command
Code generated by "jade.go"; DO NOT EDIT.
Code generated by "jade.go"; DO NOT EDIT.
custom_error command
loose_zero command
bizdemo
hertz_gorm module
hertz_jwt module
hertz_session module
tiktok_demo module
client
add_parameters command
config command
forward_proxy command
middleware command
send_request command
streaming_read command
upload_file command
file
download command
html command
html-fs command
staticFile command
upload command
hlog
custom command
logrus command
slog command
standard command
zap command
zerolog command
hz
plugin/thrift module
middleware
CORS command
basicauth command
csrf/custom_keylookup command
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
csrf/custom_next command
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
csrf/default command
custom command
gzip/default command
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
gzip/extensions command
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
gzip/paths command
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
gzip/paths_regexes command
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
pprof/default command
client command
opentelemetry
hertz/client command
hertz/server command
kitex/server command
parameter
cookie command
form command
query command
protocol
http1 command
tls command
render
html command
json command
protobuf command
text command
* Copyright 2023 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2023 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
xml command
* Copyright 2023 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2023 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
yaml_customize command
* Copyright 2023 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2023 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
reverseproxy
customize_error command
modify_response command
sse command
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
standard command
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2022 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
tls command
use_middleware command
websocket command
sentinel
hertz/client command
hertz/server command
sse
client command
server command
streaming
streaming_read command
streaming_write command
* Copyright 2023 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2023 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL