cloudwego / hertz Goto Github PK
View Code? Open in Web Editor NEWGo HTTP framework with high-performance and strong-extensibility for building micro-services.
Home Page: https://www.cloudwego.io
License: Apache License 2.0
Go HTTP framework with high-performance and strong-extensibility for building micro-services.
Home Page: https://www.cloudwego.io
License: Apache License 2.0
graceful-shutdown:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/graceful-shutdown/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/graceful-shutdown.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
forward-proxy:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/forward-proxy/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/forward-proxy.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
unit-test:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/unit-test/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/unit-test.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
We are always interested in finding out who is using Hertz, what attracted you to using it, how we can listen to your needs and if you are interested, help promote your organization.
Submit a comment in this issue to include the following information
Testing
or Production
?Organization/Company: ByteDance
Website: https://bytedance.com
Country: China
Contact: [email protected]
Usage scenario: Using Hertz to build large scale Cloud Native applications
Status: Production
As the title
Is your feature request related to a problem? Please describe.
Recently I work on the mall preject, I want to reconstruct the api layer to Hertz, but I need a swagger tool to generate api doc
Describe the solution you'd like
support Hertz swagger middleware
Describe alternatives you've considered
Additional context
Describe the solution you'd like
Add more representative easy-to-use examples
Describe the bug
in windows 11,when run hz update -I idl -idl idl/hello/hello.proto
failed :
To Reproduce
Steps to reproduce the behavior:
https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/toolkit/
hz update -I idl -idl idl/hello/hello.proto
F:\go\franchiserMgmt>F:\go\franchiserMgmt>hz update -I idl -idl idl/hello/hello.proto
plugin protoc_gen_hertz returns error: exit status 1, cause:
Could not make proto path relative: F:\go\franchiserMgmt\idl\hello\hello.proto: No such file or directory
idl gnerated
Screenshots
If applicable, add screenshots to help explain your problem.
Hertz version:
F:\go\franchiserMgmt>hz -v
hz version v0.1.0
Please provide the version of Hertz you are using.
Environment:
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\czyt\AppData\Local\go-build
set GOENV=C:\Users\czyt\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\czyt\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\czyt\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=F:\go\franchiserMgmt\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\czyt\AppData\Local\Temp\go-build85752684=/tmp/go-build -gno-record-gcc-switches
any reverse proxy example? thx
Is your feature request related to a problem? Please describe.
hertz/pkg/app/server/render/protobuf.go
Lines 59 to 62 in 48fb76f
Describe the solution you'd like
Before:
hertz/pkg/app/server/render/protobuf.go
Lines 49 to 52 in 48fb76f
Lines 866 to 869 in 48fb76f
After:
type ProtoBuf struct {
Data proto.Message
}
func (ctx *RequestContext) ProtoBuf(code int, obj proto.Message) {
ctx.Render(code, render.ProtoBuf{Data: obj})
}
Changing the type of Data in protobuf render directly is a solution. When obj doesn't implement proto.Message, compiling will failed. I think it is more useful to avoid panic in runtime.
faq:
zh web page:https://www.cloudwego.io/zh/docs/hertz/faq/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/faq/_index.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/faq
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
template:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/template/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/toolkit/template.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
Describe the solution you'd like
Add more clear comments.
tracing:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/service-governance/tracing/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/service-governance/tracing.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
Is your feature request related to a problem? Please describe.
In the case of too many service instances, we need a unified configuration center to manage the configuration
Describe the solution you'd like
Provides access to configuration centers like Nacos, apollo, etc.
Is your feature request related to a problem? Please describe.
I see hertz only support Single part ranges, i think it's better to support Multipart ranges
Describe the solution you'd like
Describe alternatives you've considered
Additional context
golang std http support it
https://github.com/golang/go/blob/be0b2a393a5a7297a3c8f42ca7d5ad3e4b15dcbe/src/net/http/fs.go#L870
monitoring:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/service-governance/monitoring/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/service-governance/monitoring.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
tls example? sry not very sure how to do it.
自身没有注册服务发现,不能网关通过服务发现代理该服务或者通过服务发现调用该服务
Api gateway is the most important part if you use microservices. No one can be found good in golang world.
how do i use unix domain socket? is this possible? any examples? thx
Describe the solution you'd like
Add or replace the way of rendering HTML in order to let the server reload HTML templates without restarting.
Describe alternatives you've considered
A timer or a file system watcher may help to decide whether to reload or not.
Additional context
Be aware of performance overhead. DO NOT reload it every time when render api is called.
Is your feature request related to a problem? Please describe.
may hertz suport Custom interface for IRoutes ?
Describe the solution you'd like
Custom([]string, string, ...app.HandlerFunc) IRoutes
and the implemention like
func (group *RouterGroup) Custom(httpMethods []string, relativePath string, handlers ...app.HandlerFunc) IRoutes {
if len(httpMethods) == 0 {
panic("can't find any http method")
}
for _, httpMethod := range httpMethods {
if matches, err := regexp.MatchString("^[A-Z]+$", httpMethod); !matches || err != nil {
panic("http method " + httpMethod + " is not valid")
}
group.handle(httpMethod, relativePath, handlers)
}
return group.returnObj()
}
Describe alternatives you've considered
Additional context
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/binding-and-validate/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/binding-and-validate.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
monitor:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/framework-exten/monitor/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/framework-exten/monitor.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
log:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/framework-exten/log/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/framework-exten/log.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
Describe alternatives you've considered
compatibility needs to be considered (the influence to the existing user)
Additional context
possible to show us how to test with wrk or apache bench? coz cant test against fasthttp etc.
got this as response
2022/05/31 14:13:56 readv(fd=59) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=58) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=57) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=56) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=55) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=54) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=53) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=51) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=49) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=48) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=47) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=46) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=45) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=44) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=43) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=41) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=40) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=39) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=38) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=36) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=34) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=33) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=32) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=31) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=30) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=29) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=28) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=27) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=26) failed: connection reset by peer
2022/05/31 14:13:56 readv(fd=25) failed: connection reset by peer
ab -n 100 -c 100 http://127.0.0.1:8888/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)...apr_pollset_poll: The timeout specified has expired (70007)
network-lib:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/framework-exten/advanced-exten/network-lib/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/framework-exten/advanced-exten/network-lib.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
Is your feature request related to a problem? Please describe.
no
Describe the solution you'd like
route.GetTransporterName()
returns the name of network library, printing an INFO log with it will work.
Describe alternatives you've considered
By the way, add a unit test for route.GetTransporterName()
to ensure the correctness.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
protocol:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/protocol/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/protocol.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
log:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/log
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/log.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
error handle:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/error-handle/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/error-handle.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
Describe the solution you'd like
作为网关用, 希望支持websocket
zh web page:https://www.cloudwego.io/zh/docs/hertz/getting-started/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/getting-started/_index.md
en folder:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/en/docs/hertz/getting-started/_index.md
Notes:
Is your feature request related to a problem? Please describe.
hertz only support gzip in fs.go. may support brotli/br?
Describe the solution you'd like
I think hertz can support it like valyala/fasthttp#880
Describe alternatives you've considered
Additional context
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/network-lib/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/network-lib.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials/basic-feature
Notes:
Is your feature request related to a problem? Please describe.
If get a none http1 request, hertz will print an error message but without an ip address of the client. It is difficult to trace the problem to the client.
Describe the solution you'd like
Add more info including the remote ip of the client may help.
toolkit:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/toolkit/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/toolkit/toolkit.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
Describe the bug
basic-auth middleware example in cloudwego.io is not working.
When I tried to build for it, an error occured.
main.go:7:2: no required module provides package github.com/cloudwego/hertz/pkg/app/middlewares/basic_auth; to add it:
go get github.com/cloudwego/hertz/pkg/app/middlewares/basic_auth
Then I found that required module should be github.com/cloudwego/hertz/pkg/app/middlewares/server/basic_auth
instead of github.com/cloudwego/hertz/pkg/app/middlewares/basic_auth
.
However, compile failed again when I solved the problem above.
# command-line-arguments
./main.go:29:23: undefined: basic_auth.AuthUserKey
AuthUserKey
is not defined in package github.com/cloudwego/hertz/pkg/app/middlewares/server/basic_auth
.
config:
zh web page:https://www.cloudwego.io/zh/docs/hertz/reference/config/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/reference/config.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/reference
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
Is your feature request related to a problem? Please describe.
In #23, if http1 server does not close connection after responding the short connection request from ab(apache bench), ab will wait until timeout.
Describe the solution you'd like
A quick way to make it work is closing the connection from the server side.
Describe alternatives you've considered
Be careful about the error processing logic. Do not break any other rule other than this "short connection" case
Additional context
Before: Hertz assumes that the initiator of the short connection will actively disconnect the connection.
version:
zh web page:https://www.cloudwego.io/zh/docs/hertz/reference/version/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/reference/version.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/reference
json:
zh web page:https://www.cloudwego.io/zh/docs/hertz/reference/json/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/reference/json.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/reference
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
README文件中,example示例地址失效:https://www.cloudwego.io/zh/docs/hertz/tutorials/example/
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/example/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/example/_index.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
how to get client's ip using hertz?
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/stream/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/basic-feature/stream.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
protocol:
zh web page:https://www.cloudwego.io/zh/docs/hertz/tutorials/framework-exten/advanced-exten/protocol/
zh doc:https://github.com/cloudwego/cloudwego.github.io/blob/main/content/zh/docs/hertz/tutorials/framework-exten/advanced-exten/protocol.md
en folder:https://github.com/cloudwego/cloudwego.github.io/tree/main/content/en/docs/hertz/tutorials
Notes:
Do not change the original layout, code style or content sequence.
Software Translator is a tool, not god, do not use the result as the final result.
Translation principle: faithfulness, expressiveness and elegance.
Submit your PR here in this repo.
Is your feature request related to a problem? Please describe.
The default log is simple, but very rudimentary
https://github.com/cloudwego/hertz-examples/
examples... not working.
Link tracing is a fundamental piece of information needed in every environment in the project, can it be started by default at the log or database level? In addition, can you give an example that is more friendly to newbies and can be used out of the box, although there is an example in the hertz example, it does not meet the basic needs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.