Skip to content

Commit

Permalink
Merge pull request #6772 from TheThingsNetwork/feature/remove-compres…
Browse files Browse the repository at this point in the history
…sion-flags

Remove HTTP compression experimental flags
  • Loading branch information
adriansmares authored Dec 13, 2023
2 parents 54a9c13 + 5efb80e commit 7c64dcf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ For details about compatibility between different releases, see the **Commitment

### Removed

- The `http.client.transport.compression` and `http.server.transport.compression` experimental flags.

### Fixed

### Security
Expand Down
7 changes: 1 addition & 6 deletions pkg/httpclient/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ import (
"github.com/klauspost/compress/gzhttp"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.thethings.network/lorawan-stack/v3/pkg/config/tlsconfig"
"go.thethings.network/lorawan-stack/v3/pkg/experimental"
"go.thethings.network/lorawan-stack/v3/pkg/telemetry/tracing"
"go.thethings.network/lorawan-stack/v3/pkg/version"
)

var transportCompressionFeatureFlag = experimental.DefineFeature("http.client.transport.compression", true)

// defaultHTTPClientTimeout is the default timeout for the HTTP client.
const defaultHTTPClientTimeout = 10 * time.Second

Expand Down Expand Up @@ -100,9 +97,7 @@ func (p *provider) HTTPClient(ctx context.Context, opts ...Option) (*http.Client
transport.TLSClientConfig = options.tlsConfig

var rt http.RoundTripper = transport
if transportCompressionFeatureFlag.GetValue(ctx) {
rt = gzhttp.Transport(rt)
}
rt = gzhttp.Transport(rt)
rt = otelhttp.NewTransport(
rt,
otelhttp.WithTracerProvider(tracing.FromContext(ctx)),
Expand Down
18 changes: 2 additions & 16 deletions pkg/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/klauspost/compress/gzhttp"
"go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"
"go.thethings.network/lorawan-stack/v3/pkg/errors"
"go.thethings.network/lorawan-stack/v3/pkg/experimental"
"go.thethings.network/lorawan-stack/v3/pkg/fillcontext"
"go.thethings.network/lorawan-stack/v3/pkg/log"
"go.thethings.network/lorawan-stack/v3/pkg/random"
Expand All @@ -41,19 +40,6 @@ import (
"gopkg.in/yaml.v2"
)

var responseCompressionFeatureFlag = experimental.DefineFeature("http.server.transport.compression", true)

func compressionMiddleware(ctx context.Context) (func(http.Handler) http.Handler, error) {
if !responseCompressionFeatureFlag.GetValue(ctx) {
return func(next http.Handler) http.Handler { return next }, nil
}
m, err := gzhttp.NewWrapper()
if err != nil {
return nil, err
}
return func(h http.Handler) http.Handler { return m(h) }, nil
}

// Registerer allows components to register their services to the web server.
type Registerer interface {
RegisterRoutes(s *Server)
Expand Down Expand Up @@ -189,7 +175,7 @@ func New(ctx context.Context, opts ...Option) (*Server, error) {
if err := proxyConfiguration.ParseAndAddTrusted(options.trustedProxies...); err != nil {
return nil, err
}
compressor, err := compressionMiddleware(ctx)
compressor, err := gzhttp.NewWrapper()
if err != nil {
return nil, err
}
Expand All @@ -200,7 +186,7 @@ func New(ctx context.Context, opts ...Option) (*Server, error) {
"text/html": webhandlers.Template,
}),
mux.MiddlewareFunc(webmiddleware.Recover()),
compressor,
func(next http.Handler) http.Handler { return compressor(next) },
otelmux.Middleware("ttn-lw-stack", otelmux.WithTracerProvider(tracing.FromContext(ctx))),
mux.MiddlewareFunc(webmiddleware.FillContext(options.contextFillers...)),
mux.MiddlewareFunc(webmiddleware.Peer()),
Expand Down

0 comments on commit 7c64dcf

Please sign in to comment.