Skip to content

Commit

Permalink
Add docs from gofiber/fiber@579d9a3
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 28, 2024
1 parent 5b3be39 commit 3c2dde8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/core/api/ctx.md
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ app.Get("/", func(c fiber.Ctx) error {

## SendFile

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.
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.

```go title="Config" title="Config"
// SendFile defines configuration options when to transfer file with SendFile.
Expand All @@ -1725,29 +1725,29 @@ type SendFile struct {
// You have to set Content-Encoding header to compress the file.
// Available compression methods are gzip, br, and zstd.
//
// Optional. Default value false
// Optional. Default: false
Compress bool `json:"compress"`
// When set to true, enables byte range requests.
//
// Optional. Default value false
// Optional. Default: false
ByteRange bool `json:"byte_range"`
// When set to true, enables direct download.
//
// Optional. Default: false.
// Optional. Default: false
Download bool `json:"download"`
// Expiration duration for inactive file handlers.
// Use a negative time.Duration to disable it.
//
// Optional. Default value 10 * time.Second.
// Optional. Default: 10 * time.Second
CacheDuration time.Duration `json:"cache_duration"`
// The value for the Cache-Control HTTP-header
// that is set on the file response. MaxAge is defined in seconds.
//
// Optional. Default value 0.
// Optional. Default: 0
MaxAge int `json:"max_age"`
}
```
Expand All @@ -1761,7 +1761,7 @@ app.Get("/not-found", func(c fiber.Ctx) error {
return c.SendFile("./public/404.html");
// Disable compression
return c.SendFile("./static/index.html", SendFile{
return c.SendFile("./static/index.html", fiber.SendFile{
Compress: false,
});
})
Expand All @@ -1783,7 +1783,7 @@ You can set `CacheDuration` config property to `-1` to disable caching.

```go title="Example"
app.Get("/file", func(c fiber.Ctx) error {
return c.SendFile("style.css", SendFile{
return c.SendFile("style.css", fiber.SendFile{
CacheDuration: -1,
})
})
Expand All @@ -1797,16 +1797,16 @@ You can use multiple SendFile with different configurations in single route. Fib
app.Get("/file", func(c fiber.Ctx) error {
switch c.Query("config") {
case "filesystem":
return c.SendFile("style.css", SendFile{
return c.SendFile("style.css", fiber.SendFile{
FS: os.DirFS(".")
})
case "filesystem-compress":
return c.SendFile("style.css", SendFile{
return c.SendFile("style.css", fiber.SendFile{
FS: os.DirFS("."),
Compress: true,
})
case "compress":
return c.SendFile("style.css", SendFile{
return c.SendFile("style.css", fiber.SendFile{
Compress: true,
})
default:
Expand Down

0 comments on commit 3c2dde8

Please sign in to comment.