Skip to content
代码片段 群组 项目
未验证 提交 ef49728c 编辑于 作者: Archish Thakkar's avatar Archish Thakkar 提交者: GitLab
浏览文件

Llint: fix for upstream internal packages

上级 4aeb37a4
No related branches found
No related tags found
无相关合并请求
/*
Package upstream provides functionality for handling upstream requests.
This package includes handlers for managing request routing and interaction with upstream servers.
*/
package upstream
import (
......@@ -29,7 +34,7 @@ func contentEncodingHandler(h http.Handler) http.Handler {
fail.Request(w, r, fmt.Errorf("contentEncodingHandler: %v", err))
return
}
defer body.Close()
defer func() { _ = body.Close() }()
r.Body = body
r.Header.Del("Content-Encoding")
......
......@@ -29,10 +29,10 @@ var (
buildHandler = metrics.NewHandlerFactory(metrics.WithNamespace(namespace), metrics.WithLabels("route"))
)
func instrumentRoute(next http.Handler, method string, regexpStr string) http.Handler {
func instrumentRoute(next http.Handler, _ string, regexpStr string) http.Handler {
return buildHandler(next, metrics.WithLabelValues(map[string]string{"route": regexpStr}))
}
func instrumentGeoProxyRoute(next http.Handler, method string, regexpStr string) http.Handler {
func instrumentGeoProxyRoute(next http.Handler, _ string, regexpStr string) http.Handler {
return promhttp.InstrumentHandlerCounter(httpGeoProxiedRequestsTotal.MustCurryWith(map[string]string{"route": regexpStr}), next)
}
......@@ -2,10 +2,11 @@ package upstream
import "net/http"
// NotFoundUnless returns a handler that forwards requests to the given handler if pass is true.
// Otherwise, it responds with a 404 Not Found status.
func NotFoundUnless(pass bool, handler http.Handler) http.Handler {
if pass {
return handler
}
return http.HandlerFunc(http.NotFound)
return http.NotFoundHandler()
}
/*
Package roundtripper provides a custom HTTP roundtripper for handling requests.
This package implements a custom HTTP transport for handling HTTP requests
with additional features such as logging, tracing, and error handling.
*/
package roundtripper
import (
......@@ -41,16 +47,17 @@ func newBackendRoundTripper(backend *url.URL, socket string, proxyHeadersTimeout
dial := transport.DialContext
if backend != nil && socket == "" {
switch {
case backend != nil && socket == "":
address := mustParseAddress(backend.Host, backend.Scheme)
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
return dial(ctx, "tcp", address)
}
} else if socket != "" {
case socket != "":
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
return dial(ctx, "unix", socket)
}
} else {
default:
panic("backend is nil and socket is empty")
}
......
......@@ -384,8 +384,8 @@ func configureRoutes(u *upstream) {
u.geoLocalRoutes = []routeEntry{
// Git and LFS requests
//
// Note that Geo already redirects pushes, with special terminal output.
// Note that excessive secondary lag can cause unexpected behavior since
// Geo already redirects pushes, with special terminal output.
// Excessive secondary lag can cause unexpected behavior since
// pulls are performed against a different source of truth. Ideally, we'd
// proxy/redirect pulls as well, when the secondary is not up-to-date.
//
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册