prototyped svg reports
This commit is contained in:
+23
-3
@@ -11,8 +11,9 @@ import (
|
||||
|
||||
type (
|
||||
htmlRes struct {
|
||||
body []byte
|
||||
res Response
|
||||
body []byte
|
||||
reader io.Reader
|
||||
res Response
|
||||
}
|
||||
)
|
||||
|
||||
@@ -24,6 +25,12 @@ func HTML(body []byte) Response {
|
||||
}
|
||||
}
|
||||
|
||||
func HTMLReader(body io.Reader) Response {
|
||||
return htmlRes{
|
||||
reader: body,
|
||||
}
|
||||
}
|
||||
|
||||
func (h htmlRes) String() string {
|
||||
if h.res != nil {
|
||||
return fmt.Sprintf(`{"body": %q, "nested": %s}`, string(h.body), h.res)
|
||||
@@ -46,6 +53,13 @@ func (h htmlRes) Redirect(code redirect.Code, to string) Response {
|
||||
|
||||
func (h htmlRes) HTML(body []byte) Response {
|
||||
h.body = body
|
||||
h.reader = nil
|
||||
return h
|
||||
}
|
||||
|
||||
func (h htmlRes) HTMLReader(body io.Reader) Response {
|
||||
h.body = nil
|
||||
h.reader = body
|
||||
return h
|
||||
}
|
||||
|
||||
@@ -133,7 +147,13 @@ func (h htmlRes) GetRedirect() (code redirect.Code, to string, ok bool) {
|
||||
}
|
||||
|
||||
func (h htmlRes) getBody() (body io.ReadCloser, ok bool, err error) {
|
||||
return io.NopCloser(bytes.NewBuffer(h.body)), true, nil
|
||||
var r io.Reader
|
||||
if h.reader != nil {
|
||||
r = h.reader
|
||||
} else {
|
||||
r = bytes.NewBuffer(h.body)
|
||||
}
|
||||
return io.NopCloser(r), true, nil
|
||||
}
|
||||
|
||||
func (h htmlRes) getCookies() []http.Cookie {
|
||||
|
||||
Reference in New Issue
Block a user