File tree Expand file tree Collapse file tree
backend/internal/web/reception/summarizer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ func (s Summarizer) Pre(r *http.Request) string {
6363}
6464
6565func (s Summarizer ) Post (crw * captured.ResponseWriter , start time.Time ) string {
66- return fmt .Sprintf ("%s %s %s bytes " ,
66+ return fmt .Sprintf ("%s %s %s" ,
6767 s .c .Magenta (crw .StatusRepresentation ()),
68- s .c .Green (time .Since (start )),
69- s .c .Cyan (crw .Header (). Get ( "Content-Length" )),
68+ s .c .Green (fmt . Sprintf ( "%dµs" , time .Since (start ). Microseconds () )),
69+ s .c .Cyan (crw .SizeRepresentation ( )),
7070 )
7171}
Original file line number Diff line number Diff line change 1+ package summarizer
2+
3+ import (
4+ "fmt"
5+ "net/http/httptest"
6+ "time"
7+
8+ "logbook/internal/web/reception/captured"
9+ )
10+
11+ func ExampleSummarizer_post () {
12+ s := New (false )
13+ w := captured .New (httptest .NewRecorder ())
14+ w .Write ([]byte ("lorem ipsum dolor sit amet" ))
15+ fmt .Println (s .Post (w , time .Now ().Add (- 20 * time .Millisecond )))
16+ // Output: 200* 20000µs 26B
17+ }
You can’t perform that action at this time.
0 commit comments