Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
added detailed comment for render.Download()
Browse files Browse the repository at this point in the history
  • Loading branch information
sio4 committed Sep 28, 2022
1 parent acb5c4b commit 76f3353
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions render/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func (r downloadRenderer) Render(w io.Writer, d Data) error {
//
// Content-Type is set using mime#TypeByExtension with the filename's extension. Content-Type will default to
// application/octet-stream if using a filename with an unknown extension.
//
// Note: the purpose of this function is not serving static files but to support
// downloading of dynamically genrated data as a file. For example, you can use
// this function when you implement CSV file download feature for the result of
// a database query.
//
// Do not use this function for large io.Reader. It could cause out of memory if
// the size of io.Reader is too big.
func Download(ctx context.Context, name string, r io.Reader) Renderer {
return downloadRenderer{
ctx: ctx,
Expand All @@ -70,6 +78,14 @@ func Download(ctx context.Context, name string, r io.Reader) Renderer {
//
// Content-Type is set using mime#TypeByExtension with the filename's extension. Content-Type will default to
// application/octet-stream if using a filename with an unknown extension.
//
// Note: the purpose of this method is not serving static files but to support
// downloading of dynamically genrated data as a file. For example, you can use
// this method when you implement CSV file download feature for the result of
// a database query.
//
// Do not use this method for large io.Reader. It could cause out of memory if
// the size of io.Reader is too big.
func (e *Engine) Download(ctx context.Context, name string, r io.Reader) Renderer {
return Download(ctx, name, r)
}
Expand Down

0 comments on commit 76f3353

Please sign in to comment.