Skip to content

Commit

Permalink
πŸ“š Doc: Update handler signature for v3 (#2794)
Browse files Browse the repository at this point in the history
πŸ“š Doc: fix handler signature for v3
  • Loading branch information
nickajacks1 authored Jan 8, 2024
1 parent 960b652 commit 956b66d
Show file tree
Hide file tree
Showing 45 changed files with 357 additions and 357 deletions.
40 changes: 20 additions & 20 deletions .github/README_az.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import "github.com/gofiber/fiber/v2"
func main() {
app := fiber.New()

app.Get("/", func(c *fiber.Ctx) error {
app.Get("/", func(c fiber.Ctx) error {
return c.SendString("Hello, World πŸ‘‹!")
})

Expand Down Expand Up @@ -178,31 +178,31 @@ func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
app.Get("/api/*", func(c fiber.Ctx) error {
msg := fmt.Sprintf("βœ‹ %s", c.Params("*"))
return c.SendString(msg) // => βœ‹ register
})

// GET /flights/LAX-SFO
app.Get("/flights/:from-:to", func(c *fiber.Ctx) error {
app.Get("/flights/:from-:to", func(c fiber.Ctx) error {
msg := fmt.Sprintf("πŸ’Έ From: %s, To: %s", c.Params("from"), c.Params("to"))
return c.SendString(msg) // => πŸ’Έ From: LAX, To: SFO
})

// GET /dictionary.txt
app.Get("/:file.:ext", func(c *fiber.Ctx) error {
app.Get("/:file.:ext", func(c fiber.Ctx) error {
msg := fmt.Sprintf("πŸ“ƒ %s.%s", c.Params("file"), c.Params("ext"))
return c.SendString(msg) // => πŸ“ƒ dictionary.txt
})

// GET /john/75
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) error {
app.Get("/:name/:age/:gender?", func(c fiber.Ctx) error {
msg := fmt.Sprintf("πŸ‘΄ %s is %s years old", c.Params("name"), c.Params("age"))
return c.SendString(msg) // => πŸ‘΄ john is 75 years old
})

// GET /john
app.Get("/:name", func(c *fiber.Ctx) error {
app.Get("/:name", func(c fiber.Ctx) error {
msg := fmt.Sprintf("Hello, %s πŸ‘‹!", c.Params("name"))
return c.SendString(msg) // => Hello john πŸ‘‹!
})
Expand All @@ -219,7 +219,7 @@ func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
app.Get("/api/*", func(c fiber.Ctx) error {
msg := fmt.Sprintf("βœ‹ %s", c.Params("*"))
return c.SendString(msg) // => βœ‹ register
}).Name("api")
Expand Down Expand Up @@ -271,19 +271,19 @@ func main() {
app := fiber.New()

// Match any route
app.Use(func(c *fiber.Ctx) error {
app.Use(func(c fiber.Ctx) error {
fmt.Println("πŸ₯‡ First handler")
return c.Next()
})

// Match all routes starting with /api
app.Use("/api", func(c *fiber.Ctx) error {
app.Use("/api", func(c fiber.Ctx) error {
fmt.Println("πŸ₯ˆ Second handler")
return c.Next()
})

// GET /api/list
app.Get("/api/list", func(c *fiber.Ctx) error {
app.Get("/api/list", func(c fiber.Ctx) error {
fmt.Println("πŸ₯‰ Last handler")
return c.SendString("Hello, World πŸ‘‹!")
})
Expand Down Expand Up @@ -323,7 +323,7 @@ func main() {
})

// VΙ™ indi `./views/home.pug` template-i bu ΕŸΙ™kildΙ™ Γ§ağıra bilΙ™rsiniz:
app.Get("/", func(c *fiber.Ctx) error {
app.Get("/", func(c fiber.Ctx) error {
return c.Render("home", fiber.Map{
"title": "Homepage",
"year": 1999,
Expand All @@ -339,12 +339,12 @@ func main() {
πŸ“– [Group](https://docs.gofiber.io/api/app#group)

```go
func middleware(c *fiber.Ctx) error {
func middleware(c fiber.Ctx) error {
fmt.Println("Don't mind me!")
return c.Next()
}

func handler(c *fiber.Ctx) error {
func handler(c fiber.Ctx) error {
return c.SendString(c.Path())
}

Expand Down Expand Up @@ -433,16 +433,16 @@ func main() {

app.Static("/", "./public")

app.Get("/demo", func(c *fiber.Ctx) error {
app.Get("/demo", func(c fiber.Ctx) error {
return c.SendString("This is a demo!")
})

app.Post("/register", func(c *fiber.Ctx) error {
app.Post("/register", func(c fiber.Ctx) error {
return c.SendString("Welcome!")
})

// Sonuncu middleware-in hΙ™r şeyΙ™ uyğunlaşdΔ±rΔ±lmasΔ±
app.Use(func(c *fiber.Ctx) error {
app.Use(func(c fiber.Ctx) error {
return c.SendStatus(404)
// => 404 "Not Found"
})
Expand All @@ -464,12 +464,12 @@ type User struct {
func main() {
app := fiber.New()

app.Get("/user", func(c *fiber.Ctx) error {
app.Get("/user", func(c fiber.Ctx) error {
return c.JSON(&User{"John", 20})
// => {"name":"John", "age":20}
})

app.Get("/json", func(c *fiber.Ctx) error {
app.Get("/json", func(c fiber.Ctx) error {
return c.JSON(fiber.Map{
"success": true,
"message": "Hi John!",
Expand Down Expand Up @@ -528,7 +528,7 @@ import (
func main() {
app := fiber.New()

app.Get("/sse", func(c *fiber.Ctx) error {
app.Get("/sse", func(c fiber.Ctx) error {
c.Set("Content-Type", "text/event-stream")
c.Set("Cache-Control", "no-cache")
c.Set("Connection", "keep-alive")
Expand Down Expand Up @@ -571,7 +571,7 @@ func main() {

app.Use(recover.New())

app.Get("/", func(c *fiber.Ctx) error {
app.Get("/", func(c fiber.Ctx) error {
panic("normally this would crash your app")
})

Expand Down
40 changes: 20 additions & 20 deletions .github/README_eg.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ import "github.com/gofiber/fiber/v2"
func main() {
app := fiber.New()

app.Get("/", func(c *fiber.Ctx) error {
app.Get("/", func(c fiber.Ctx) error {
return c.SendString("Hello, World πŸ‘‹!")
})

Expand Down Expand Up @@ -178,31 +178,31 @@ func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
app.Get("/api/*", func(c fiber.Ctx) error {
msg := fmt.Sprintf("βœ‹ %s", c.Params("*"))
return c.SendString(msg) // => βœ‹ register
})

// GET /flights/LAX-SFO
app.Get("/flights/:from-:to", func(c *fiber.Ctx) error {
app.Get("/flights/:from-:to", func(c fiber.Ctx) error {
msg := fmt.Sprintf("πŸ’Έ From: %s, To: %s", c.Params("from"), c.Params("to"))
return c.SendString(msg) // => πŸ’Έ From: LAX, To: SFO
})

// GET /dictionary.txt
app.Get("/:file.:ext", func(c *fiber.Ctx) error {
app.Get("/:file.:ext", func(c fiber.Ctx) error {
msg := fmt.Sprintf("πŸ“ƒ %s.%s", c.Params("file"), c.Params("ext"))
return c.SendString(msg) // => πŸ“ƒ dictionary.txt
})

// GET /john/75
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) error {
app.Get("/:name/:age/:gender?", func(c fiber.Ctx) error {
msg := fmt.Sprintf("πŸ‘΄ %s is %s years old", c.Params("name"), c.Params("age"))
return c.SendString(msg) // => πŸ‘΄ john is 75 years old
})

// GET /john
app.Get("/:name", func(c *fiber.Ctx) error {
app.Get("/:name", func(c fiber.Ctx) error {
msg := fmt.Sprintf("Hello, %s πŸ‘‹!", c.Params("name"))
return c.SendString(msg) // => Hello john πŸ‘‹!
})
Expand All @@ -219,7 +219,7 @@ func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
app.Get("/api/*", func(c fiber.Ctx) error {
msg := fmt.Sprintf("βœ‹ %s", c.Params("*"))
return c.SendString(msg) // => βœ‹ register
}).Name("api")
Expand Down Expand Up @@ -271,19 +271,19 @@ func main() {
app := fiber.New()

// Match any route
app.Use(func(c *fiber.Ctx) error {
app.Use(func(c fiber.Ctx) error {
fmt.Println("πŸ₯‡ First handler")
return c.Next()
})

// Match all routes starting with /api
app.Use("/api", func(c *fiber.Ctx) error {
app.Use("/api", func(c fiber.Ctx) error {
fmt.Println("πŸ₯ˆ Second handler")
return c.Next()
})

// GET /api/list
app.Get("/api/list", func(c *fiber.Ctx) error {
app.Get("/api/list", func(c fiber.Ctx) error {
fmt.Println("πŸ₯‰ Last handler")
return c.SendString("Hello, World πŸ‘‹!")
})
Expand Down Expand Up @@ -323,7 +323,7 @@ func main() {
})

// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) error {
app.Get("/", func(c fiber.Ctx) error {
return c.Render("home", fiber.Map{
"title": "Homepage",
"year": 1999,
Expand All @@ -339,12 +339,12 @@ func main() {
πŸ“– [Group](https://docs.gofiber.io/api/app#group)

```go
func middleware(c *fiber.Ctx) error {
func middleware(c fiber.Ctx) error {
fmt.Println("Don't mind me!")
return c.Next()
}

func handler(c *fiber.Ctx) error {
func handler(c fiber.Ctx) error {
return c.SendString(c.Path())
}

Expand Down Expand Up @@ -433,16 +433,16 @@ func main() {

app.Static("/", "./public")

app.Get("/demo", func(c *fiber.Ctx) error {
app.Get("/demo", func(c fiber.Ctx) error {
return c.SendString("This is a demo!")
})

app.Post("/register", func(c *fiber.Ctx) error {
app.Post("/register", func(c fiber.Ctx) error {
return c.SendString("Welcome!")
})

// Last middleware to match anything
app.Use(func(c *fiber.Ctx) error {
app.Use(func(c fiber.Ctx) error {
return c.SendStatus(404)
// => 404 "Not Found"
})
Expand All @@ -464,12 +464,12 @@ type User struct {
func main() {
app := fiber.New()

app.Get("/user", func(c *fiber.Ctx) error {
app.Get("/user", func(c fiber.Ctx) error {
return c.JSON(&User{"John", 20})
// => {"name":"John", "age":20}
})

app.Get("/json", func(c *fiber.Ctx) error {
app.Get("/json", func(c fiber.Ctx) error {
return c.JSON(fiber.Map{
"success": true,
"message": "Hi John!",
Expand Down Expand Up @@ -528,7 +528,7 @@ import (
func main() {
app := fiber.New()

app.Get("/sse", func(c *fiber.Ctx) error {
app.Get("/sse", func(c fiber.Ctx) error {
c.Set("Content-Type", "text/event-stream")
c.Set("Cache-Control", "no-cache")
c.Set("Connection", "keep-alive")
Expand Down Expand Up @@ -571,7 +571,7 @@ func main() {

app.Use(recover.New())

app.Get("/", func(c *fiber.Ctx) error {
app.Get("/", func(c fiber.Ctx) error {
panic("normally this would crash your app")
})

Expand Down
Loading

0 comments on commit 956b66d

Please sign in to comment.