mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
remove unused WebTrace and minio/rpc dependency
This commit is contained in:
parent
23ef25b57a
commit
294bafd58b
@ -30,11 +30,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"github.com/minio/madmin-go"
|
"github.com/minio/madmin-go"
|
||||||
"github.com/minio/minio/internal/handlers"
|
"github.com/minio/minio/internal/handlers"
|
||||||
"github.com/minio/minio/internal/logger"
|
"github.com/minio/minio/internal/logger"
|
||||||
jsonrpc "github.com/minio/rpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// recordRequest - records the first recLen bytes
|
// recordRequest - records the first recLen bytes
|
||||||
@ -110,75 +108,6 @@ func getOpName(name string) (op string) {
|
|||||||
return op
|
return op
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebTrace gets trace of web request
|
|
||||||
func WebTrace(ri *jsonrpc.RequestInfo) madmin.TraceInfo {
|
|
||||||
r := ri.Request
|
|
||||||
w := ri.ResponseWriter
|
|
||||||
|
|
||||||
name := ri.Method
|
|
||||||
// Setup a http request body recorder
|
|
||||||
reqHeaders := r.Header.Clone()
|
|
||||||
reqHeaders.Set("Host", r.Host)
|
|
||||||
if len(r.TransferEncoding) == 0 {
|
|
||||||
reqHeaders.Set("Content-Length", strconv.Itoa(int(r.ContentLength)))
|
|
||||||
} else {
|
|
||||||
reqHeaders.Set("Transfer-Encoding", strings.Join(r.TransferEncoding, ","))
|
|
||||||
}
|
|
||||||
|
|
||||||
now := time.Now().UTC()
|
|
||||||
t := madmin.TraceInfo{TraceType: madmin.TraceHTTP, FuncName: name, Time: now}
|
|
||||||
t.NodeName = r.Host
|
|
||||||
if globalIsDistErasure {
|
|
||||||
t.NodeName = globalLocalNodeName
|
|
||||||
}
|
|
||||||
if t.NodeName == "" {
|
|
||||||
t.NodeName = globalLocalNodeName
|
|
||||||
}
|
|
||||||
|
|
||||||
// strip only standard port from the host address
|
|
||||||
if host, port, err := net.SplitHostPort(t.NodeName); err == nil {
|
|
||||||
if port == "443" || port == "80" {
|
|
||||||
t.NodeName = host
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
rq := madmin.TraceRequestInfo{
|
|
||||||
Time: now,
|
|
||||||
Proto: r.Proto,
|
|
||||||
Method: r.Method,
|
|
||||||
Path: SlashSeparator + pathJoin(vars["bucket"], vars["object"]),
|
|
||||||
RawQuery: redactLDAPPwd(r.URL.RawQuery),
|
|
||||||
Client: handlers.GetSourceIP(r),
|
|
||||||
Headers: reqHeaders,
|
|
||||||
}
|
|
||||||
|
|
||||||
rw, ok := w.(*logger.ResponseWriter)
|
|
||||||
if ok {
|
|
||||||
rs := madmin.TraceResponseInfo{
|
|
||||||
Time: time.Now().UTC(),
|
|
||||||
Headers: rw.Header().Clone(),
|
|
||||||
StatusCode: rw.StatusCode,
|
|
||||||
Body: logger.BodyPlaceHolder,
|
|
||||||
}
|
|
||||||
|
|
||||||
if rs.StatusCode == 0 {
|
|
||||||
rs.StatusCode = http.StatusOK
|
|
||||||
}
|
|
||||||
|
|
||||||
t.RespInfo = rs
|
|
||||||
t.CallStats = madmin.TraceCallStats{
|
|
||||||
Latency: rs.Time.Sub(rw.StartTime),
|
|
||||||
InputBytes: int(r.ContentLength),
|
|
||||||
OutputBytes: rw.Size(),
|
|
||||||
TimeToFirstByte: rw.TimeToFirstByte,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t.ReqInfo = rq
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trace gets trace of http request
|
// Trace gets trace of http request
|
||||||
func Trace(f http.HandlerFunc, logBody bool, w http.ResponseWriter, r *http.Request) madmin.TraceInfo {
|
func Trace(f http.HandlerFunc, logBody bool, w http.ResponseWriter, r *http.Request) madmin.TraceInfo {
|
||||||
name := getOpName(runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name())
|
name := getOpName(runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name())
|
||||||
|
@ -96,6 +96,11 @@ func isNotIPv4(host string) bool {
|
|||||||
// port "80" and "443" before displaying on the startup
|
// port "80" and "443" before displaying on the startup
|
||||||
// banner. Returns a new list of API endpoints.
|
// banner. Returns a new list of API endpoints.
|
||||||
func stripStandardPorts(apiEndpoints []string, host string) (newAPIEndpoints []string) {
|
func stripStandardPorts(apiEndpoints []string, host string) (newAPIEndpoints []string) {
|
||||||
|
if len(apiEndpoints) == 1 && globalBrowserRedirectURL != nil {
|
||||||
|
if apiEndpoints[0] == globalBrowserRedirectURL.String() {
|
||||||
|
return []string{globalBrowserRedirectURL.String()}
|
||||||
|
}
|
||||||
|
}
|
||||||
newAPIEndpoints = make([]string, len(apiEndpoints))
|
newAPIEndpoints = make([]string, len(apiEndpoints))
|
||||||
// Check all API endpoints for standard ports and strip them.
|
// Check all API endpoints for standard ports and strip them.
|
||||||
for i, apiEndpoint := range apiEndpoints {
|
for i, apiEndpoint := range apiEndpoints {
|
||||||
|
1
go.mod
1
go.mod
@ -49,7 +49,6 @@ require (
|
|||||||
github.com/minio/minio-go/v7 v7.0.13-0.20210715203016-9e713532886e
|
github.com/minio/minio-go/v7 v7.0.13-0.20210715203016-9e713532886e
|
||||||
github.com/minio/parquet-go v1.0.0
|
github.com/minio/parquet-go v1.0.0
|
||||||
github.com/minio/pkg v1.0.10
|
github.com/minio/pkg v1.0.10
|
||||||
github.com/minio/rpc v1.0.0
|
|
||||||
github.com/minio/selfupdate v0.3.1
|
github.com/minio/selfupdate v0.3.1
|
||||||
github.com/minio/sha256-simd v1.0.0
|
github.com/minio/sha256-simd v1.0.0
|
||||||
github.com/minio/simdjson-go v0.2.1
|
github.com/minio/simdjson-go v0.2.1
|
||||||
|
2
go.sum
2
go.sum
@ -1044,8 +1044,6 @@ github.com/minio/pkg v1.0.4/go.mod h1:obU54TZ9QlMv0TRaDgQ/JTzf11ZSXxnSfLrm4tMtBP
|
|||||||
github.com/minio/pkg v1.0.8/go.mod h1:32x/3OmGB0EOi1N+3ggnp+B5VFkSBBB9svPMVfpnf14=
|
github.com/minio/pkg v1.0.8/go.mod h1:32x/3OmGB0EOi1N+3ggnp+B5VFkSBBB9svPMVfpnf14=
|
||||||
github.com/minio/pkg v1.0.10 h1:fohpAm/0ttQFf4BzmzH5r6A9JUIfg63AyGCPM0f9/9U=
|
github.com/minio/pkg v1.0.10 h1:fohpAm/0ttQFf4BzmzH5r6A9JUIfg63AyGCPM0f9/9U=
|
||||||
github.com/minio/pkg v1.0.10/go.mod h1:32x/3OmGB0EOi1N+3ggnp+B5VFkSBBB9svPMVfpnf14=
|
github.com/minio/pkg v1.0.10/go.mod h1:32x/3OmGB0EOi1N+3ggnp+B5VFkSBBB9svPMVfpnf14=
|
||||||
github.com/minio/rpc v1.0.0 h1:tJCHyLfQF6k6HlMQFpKy2FO/7lc2WP8gLDGMZp18E70=
|
|
||||||
github.com/minio/rpc v1.0.0/go.mod h1:b9xqF7J0xeMXr0cM4pnBlP7Te7PDsG5JrRxl5dG6Ldk=
|
|
||||||
github.com/minio/selfupdate v0.3.1 h1:BWEFSNnrZVMUWXbXIgLDNDjbejkmpAmZvy/nCz1HlEs=
|
github.com/minio/selfupdate v0.3.1 h1:BWEFSNnrZVMUWXbXIgLDNDjbejkmpAmZvy/nCz1HlEs=
|
||||||
github.com/minio/selfupdate v0.3.1/go.mod h1:b8ThJzzH7u2MkF6PcIra7KaXO9Khf6alWPvMSyTDCFM=
|
github.com/minio/selfupdate v0.3.1/go.mod h1:b8ThJzzH7u2MkF6PcIra7KaXO9Khf6alWPvMSyTDCFM=
|
||||||
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||||
|
Loading…
Reference in New Issue
Block a user