📚 Doc: Update intro.md Static Files section (#3303)

Update intro.md Static Files section

In v3 the apps Static method has been removed and its functionality has been moved to the static middleware.
The given code example has been updated accordingly.
pull/3305/head
Lars Schumann 2025-02-10 08:35:56 +01:00 committed by GitHub
parent 7af9c93f5b
commit 6148c6fe29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -163,7 +163,7 @@ app.Get("/api/*", func(c fiber.Ctx) error {
### Static Files
To serve static files such as **images**, **CSS**, and **JavaScript** files, use the `Static` method with a directory path. For more information, refer to the [static middleware](./middleware/static.md).
To serve static files such as **images**, **CSS**, and **JavaScript** files, use the [static middleware](./middleware/static.md).
Use the following code to serve files in a directory named `./public`:
@ -172,12 +172,13 @@ package main
import (
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/static"
)
func main() {
app := fiber.New()
app.Static("/", "./public")
app.Use("/", static.New("./public"))
app.Listen(":3000")
}