Skip to content

Commit 3c2dde8

Browse files
Add docs from gofiber/fiber@579d9a3
1 parent 5b3be39 commit 3c2dde8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/core/api/ctx.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ app.Get("/", func(c fiber.Ctx) error {
17091709

17101710
## SendFile
17111711

1712-
Transfers the file from the given path. Sets the [Content-Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) response HTTP header field based on the **filenames** extension.
1712+
Transfers the file from the given path. Sets the [Content-Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) response HTTP header field based on the **file** extension or format.
17131713

17141714
```go title="Config" title="Config"
17151715
// SendFile defines configuration options when to transfer file with SendFile.
@@ -1725,29 +1725,29 @@ type SendFile struct {
17251725
// You have to set Content-Encoding header to compress the file.
17261726
// Available compression methods are gzip, br, and zstd.
17271727
//
1728-
// Optional. Default value false
1728+
// Optional. Default: false
17291729
Compress bool `json:"compress"`
17301730
17311731
// When set to true, enables byte range requests.
17321732
//
1733-
// Optional. Default value false
1733+
// Optional. Default: false
17341734
ByteRange bool `json:"byte_range"`
17351735
17361736
// When set to true, enables direct download.
17371737
//
1738-
// Optional. Default: false.
1738+
// Optional. Default: false
17391739
Download bool `json:"download"`
17401740
17411741
// Expiration duration for inactive file handlers.
17421742
// Use a negative time.Duration to disable it.
17431743
//
1744-
// Optional. Default value 10 * time.Second.
1744+
// Optional. Default: 10 * time.Second
17451745
CacheDuration time.Duration `json:"cache_duration"`
17461746
17471747
// The value for the Cache-Control HTTP-header
17481748
// that is set on the file response. MaxAge is defined in seconds.
17491749
//
1750-
// Optional. Default value 0.
1750+
// Optional. Default: 0
17511751
MaxAge int `json:"max_age"`
17521752
}
17531753
```
@@ -1761,7 +1761,7 @@ app.Get("/not-found", func(c fiber.Ctx) error {
17611761
return c.SendFile("./public/404.html");
17621762
17631763
// Disable compression
1764-
return c.SendFile("./static/index.html", SendFile{
1764+
return c.SendFile("./static/index.html", fiber.SendFile{
17651765
Compress: false,
17661766
});
17671767
})
@@ -1783,7 +1783,7 @@ You can set `CacheDuration` config property to `-1` to disable caching.
17831783

17841784
```go title="Example"
17851785
app.Get("/file", func(c fiber.Ctx) error {
1786-
return c.SendFile("style.css", SendFile{
1786+
return c.SendFile("style.css", fiber.SendFile{
17871787
CacheDuration: -1,
17881788
})
17891789
})
@@ -1797,16 +1797,16 @@ You can use multiple SendFile with different configurations in single route. Fib
17971797
app.Get("/file", func(c fiber.Ctx) error {
17981798
switch c.Query("config") {
17991799
case "filesystem":
1800-
return c.SendFile("style.css", SendFile{
1800+
return c.SendFile("style.css", fiber.SendFile{
18011801
FS: os.DirFS(".")
18021802
})
18031803
case "filesystem-compress":
1804-
return c.SendFile("style.css", SendFile{
1804+
return c.SendFile("style.css", fiber.SendFile{
18051805
FS: os.DirFS("."),
18061806
Compress: true,
18071807
})
18081808
case "compress":
1809-
return c.SendFile("style.css", SendFile{
1809+
return c.SendFile("style.css", fiber.SendFile{
18101810
Compress: true,
18111811
})
18121812
default:

0 commit comments

Comments
 (0)