add Request.String(), Response.String()

This commit is contained in:
aler9
2020-12-07 22:49:33 +01:00
parent 3631309f9f
commit eb7ebc5543
2 changed files with 16 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package base
import (
"bufio"
"bytes"
"fmt"
"strconv"
)
@@ -133,3 +134,10 @@ func (req Request) Write(bw *bufio.Writer) error {
return bw.Flush()
}
// String implements fmt.Stringer.
func (req Request) String() string {
buf := bytes.NewBuffer(nil)
req.Write(bufio.NewWriter(buf))
return buf.String()
}

View File

@@ -2,6 +2,7 @@ package base
import (
"bufio"
"bytes"
"fmt"
"strconv"
)
@@ -214,3 +215,10 @@ func (res Response) Write(bw *bufio.Writer) error {
return bw.Flush()
}
// String implements fmt.Stringer.
func (res Response) String() string {
buf := bytes.NewBuffer(nil)
res.Write(bufio.NewWriter(buf))
return buf.String()
}