Files
Matthieu MORELandGitHub 27015cf3b9 [chore]: fix staticcheck exclusions (#12792)
#### Description

Fixes staticcheck rules which where disabled with golangci-lint v2
upgrade

Signed-off-by: Matthieu MOREL <[email protected]>
2025-04-02 20:07:55 +00:00

39 lines
1.0 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package internal // import "go.opentelemetry.io/collector/config/confighttp/internal"
import (
"io"
"net/http"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
// ToServerOptions has options that change the behavior of the HTTP server
// returned by ServerConfig.ToServer().
type ToServerOptions struct {
ErrHandler func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int)
Decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error)
OtelhttpOpts []otelhttp.Option
}
func (tso *ToServerOptions) Apply(opts ...ToServerOption) {
for _, o := range opts {
o.apply(tso)
}
}
// ToServerOption is an option to change the behavior of the HTTP server
// returned by ServerConfig.ToServer().
type ToServerOption interface {
apply(*ToServerOptions)
}
// ToServerOptionFunc converts a function into ToServerOption interface.
type ToServerOptionFunc func(*ToServerOptions)
func (of ToServerOptionFunc) apply(e *ToServerOptions) {
of(e)
}