Files
go-away/utils/http_legacy.go
WeebDataHoarder 0ca8e277f9 Patches to bring compatibility to Go 1.22
* Disabled container building
* No TLS Fingerprinting
* HTTP/2 H2C uses golang.org/x/net/http2/h2c
* html DOM walking uses custom function instead of iterator
* Pinned these packages to latest compatible releases:
 * github.com/go-jose/go-jose/v4 v4.0.5
 * golang.org/x/crypto v0.33.0
 * golang.org/x/net v0.37.0
 * golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
 * golang.org/x/text v0.22.0
 * google.golang.org/genproto/googleapis v0.0.0-20240826202546-f6391c0de4c7
2025-05-04 15:43:36 +02:00

29 lines
454 B
Go

//go:build go1.22 || go1.23
package utils
import (
"crypto/tls"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"net/http"
)
func NewServer(handler http.Handler, tlsConfig *tls.Config) *http.Server {
if tlsConfig == nil {
h2s := &http2.Server{}
h1s := &http.Server{
Handler: h2c.NewHandler(handler, h2s),
}
return h1s
} else {
server := &http.Server{
TLSConfig: tlsConfig,
Handler: handler,
}
return server
}
}