mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-18 14:39:49 +02:00
style: coed cleanup and fix styling
This commit is contained in:
@@ -139,12 +139,12 @@ func logEntry() []byte {
|
||||
Format: FormatJSON,
|
||||
})
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("hello"))
|
||||
_, _ = w.Write([]byte("hello"))
|
||||
}))
|
||||
srv.URL = "http://localhost:8080"
|
||||
defer srv.Close()
|
||||
// make a request to the server
|
||||
req, _ := http.NewRequest("GET", srv.URL, nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, srv.URL, nil)
|
||||
res := httptest.NewRecorder()
|
||||
// server the request
|
||||
srv.Config.Handler.ServeHTTP(res, req)
|
||||
@@ -179,7 +179,10 @@ func TestReset(t *testing.T) {
|
||||
t.Errorf("scanner error: %v", err)
|
||||
}
|
||||
expect.Equal(t, linesRead, nLines)
|
||||
s.Reset()
|
||||
err = s.Reset()
|
||||
if err != nil {
|
||||
t.Errorf("failed to reset scanner: %v", err)
|
||||
}
|
||||
|
||||
linesRead = 0
|
||||
for s.Scan() {
|
||||
@@ -191,7 +194,7 @@ func TestReset(t *testing.T) {
|
||||
expect.Equal(t, linesRead, nLines)
|
||||
}
|
||||
|
||||
// 100000 log entries
|
||||
// 100000 log entries.
|
||||
func BenchmarkBackScanner(b *testing.B) {
|
||||
mockFile := NewMockFile()
|
||||
line := logEntry()
|
||||
|
||||
@@ -94,32 +94,6 @@ func (f *CombinedFormatter) AppendRequestLog(line []byte, req *http.Request, res
|
||||
return line
|
||||
}
|
||||
|
||||
type zeroLogStringStringMapMarshaler struct {
|
||||
values map[string]string
|
||||
}
|
||||
|
||||
func (z *zeroLogStringStringMapMarshaler) MarshalZerologObject(e *zerolog.Event) {
|
||||
if len(z.values) == 0 {
|
||||
return
|
||||
}
|
||||
for k, v := range z.values {
|
||||
e.Str(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
type zeroLogStringStringSliceMapMarshaler struct {
|
||||
values map[string][]string
|
||||
}
|
||||
|
||||
func (z *zeroLogStringStringSliceMapMarshaler) MarshalZerologObject(e *zerolog.Event) {
|
||||
if len(z.values) == 0 {
|
||||
return
|
||||
}
|
||||
for k, v := range z.values {
|
||||
e.Strs(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) AppendRequestLog(line []byte, req *http.Request, res *http.Response) []byte {
|
||||
query := f.cfg.Query.ZerologQuery(req.URL.Query())
|
||||
headers := f.cfg.Headers.ZerologHeaders(req.Header)
|
||||
|
||||
Reference in New Issue
Block a user