chore: refactor log limit in rest (#3572)

This commit is contained in:
Kevin Wan
2023-09-16 22:33:30 +08:00
committed by GitHub
parent cc21f5fae2
commit 0dcede6457
7 changed files with 50 additions and 15 deletions

View File

@@ -28,6 +28,13 @@ func DupReadCloser(reader io.ReadCloser) (io.ReadCloser, io.ReadCloser) {
return io.NopCloser(tee), io.NopCloser(&buf)
}
// KeepSpace customizes the reading functions to keep leading and tailing spaces.
func KeepSpace() TextReadOption {
return func(o *textReadOptions) {
o.keepSpace = true
}
}
// LimitDupReadCloser returns two io.ReadCloser that read from the first will be written to the second.
// But the second io.ReadCloser is limited to up to n bytes.
// The first returned reader needs to be read first, because the content
@@ -38,13 +45,6 @@ func LimitDupReadCloser(reader io.ReadCloser, n int64) (io.ReadCloser, io.ReadCl
return io.NopCloser(tee), io.NopCloser(&buf)
}
// KeepSpace customizes the reading functions to keep leading and tailing spaces.
func KeepSpace() TextReadOption {
return func(o *textReadOptions) {
o.keepSpace = true
}
}
// ReadBytes reads exactly the bytes with the length of len(buf)
func ReadBytes(reader io.Reader, buf []byte) error {
var got int