Skip to content

Commit

Permalink
allow to customize http2 server
Browse files Browse the repository at this point in the history
  • Loading branch information
lqs committed Dec 26, 2024
1 parent 58e56c6 commit af192b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Config struct {
GrpcServerOptions []grpc.ServerOption
OnStarted func()
AllowPrivateNetwork bool
HTTP2Server *http2.Server
}

type server struct {
Expand Down Expand Up @@ -58,7 +59,10 @@ func (s *server) GetConnStateMap() map[net.Conn]http.ConnState {
func (s *server) StartAndWait(ctx context.Context) error {
var connectionClose atomic.Bool

http2Server := &http2.Server{}
http2Server := s.config.HTTP2Server
if http2Server == nil {
http2Server = &http2.Server{}
}
handler, wait := s.newHandler(http2Server, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if connectionClose.Load() {
w.Header().Set("Connection", "close")
Expand Down

0 comments on commit af192b0

Please sign in to comment.