From f4c8d5d8e2e04d78b6eb3e9e73beb5e493f2a9c0 Mon Sep 17 00:00:00 2001 From: StalkR Date: Thu, 3 Oct 2024 00:40:46 +0200 Subject: [PATCH] response: clarify Content-Disposition, close file in Stream example It wasn't clear to me what were the differences between `Context#File`, `Context#Attachment` and `Context#Inline` - reading the source made it clearer: the former 2 are referring to sending `Content-Disposition` with `attachment` and `inline`, which makes sense. Adding missing `defer f.Close()` in the `Context#Stream` example. I also checked, it takes an `io.Reader` not an `io.ReadCloser` so it couldn't delegate the close to `Context#Stream`. --- website/docs/guide/response.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/website/docs/guide/response.md b/website/docs/guide/response.md index e131e350..67a297ee 100644 --- a/website/docs/guide/response.md +++ b/website/docs/guide/response.md @@ -244,7 +244,7 @@ func(c echo.Context) error { ## Send Attachment `Context#Attachment(file, name string)` is similar to `File()` except that it is -used to send file as attachment with provided name. +used to send file as `Content-Disposition: attachment` with provided name. *Example* @@ -257,7 +257,7 @@ func(c echo.Context) error { ## Send Inline `Context#Inline(file, name string)` is similar to `File()` except that it is -used to send file as inline with provided name. +used to send file as `Content-Disposition: inline` with provided name. *Example* @@ -296,6 +296,7 @@ func(c echo.Context) error { if err != nil { return err } + defer f.Close() return c.Stream(http.StatusOK, "image/png", f) } ```