change BufferPDF to BufferFile to support any kind of file

This commit is contained in:
Zeni Kim 2024-12-22 10:42:56 -05:00
parent 90564daa5b
commit 4968da25f3

View file

@ -28,10 +28,10 @@ type header struct {
} }
// TODO add doc // TODO add doc
func (rs *Response) BufferPDF(name string, b bytes.Buffer) *Response { func (rs *Response) BufferFile(name string, filetype string, b bytes.Buffer) *Response {
if rs.isTerminated == false { if rs.isTerminated == false {
rs.HttpResponseWriter.Header().Add("Content-Type", "application/pdf") rs.HttpResponseWriter.Header().Add("Content-Type", filetype)
rs.HttpResponseWriter.Header().Add("Content-Disposition", "attachment; filename="+name) rs.HttpResponseWriter.Header().Add("Content-Disposition", "attachment; filename="+name)
b.WriteTo(rs.HttpResponseWriter) b.WriteTo(rs.HttpResponseWriter)
} }