mirror of
https://github.com/pgsty/minio.git
synced 2026-07-23 22:16:15 +03:00
Add detailed parameter tracing + custom prefix (#18518)
* Allow per handler custom prefix. * Add automatic parameter extraction
This commit is contained in:
@@ -19,6 +19,9 @@ package grid
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/tinylib/msgp/msgp"
|
||||
)
|
||||
@@ -117,6 +120,31 @@ func NewMSSWith(m map[string]string) *MSS {
|
||||
return &m2
|
||||
}
|
||||
|
||||
// ToQuery constructs a URL query string from the MSS, including "?" if there are any keys.
|
||||
func (m MSS) ToQuery() string {
|
||||
if len(m) == 0 {
|
||||
return ""
|
||||
}
|
||||
var buf strings.Builder
|
||||
buf.WriteByte('?')
|
||||
keys := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
v := m[k]
|
||||
keyEscaped := url.QueryEscape(k)
|
||||
if buf.Len() > 1 {
|
||||
buf.WriteByte('&')
|
||||
}
|
||||
buf.WriteString(keyEscaped)
|
||||
buf.WriteByte('=')
|
||||
buf.WriteString(url.QueryEscape(v))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// NewBytes returns a new Bytes.
|
||||
func NewBytes() *Bytes {
|
||||
b := Bytes(GetByteBuffer()[:0])
|
||||
|
||||
Reference in New Issue
Block a user