Skip to content

Commit

Permalink
[v3 Maintenance]: Consolidate and Document Core Changes in v3
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneWerner87 committed Jun 7, 2024
1 parent 046b4a9 commit e561026
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,51 @@ You have to put `*` to the end of the route if you don't define static route wit

### 🗺 Router

The signatures for [`Add`](#middleware-registration) and [`Route`](#route-chaining) have been changed.

To migrate [`Add`](#middleware-registration) you must change the `methods` in a slice.

```go
// Before
app.Add(fiber.MethodPost, "/api", myHandler)
```

```go
// After
app.Add([]string{fiber.MethodPost}, "/api", myHandler)
```

To migrate [`Route`](#route-chaining) you need to read [this](#route-chaining).

```go
// Before
app.Route("/api", func(apiGrp Router) {
apiGrp.Route("/user/:id?", func(userGrp Router) {
userGrp.Get("/", func(c fiber.Ctx) error {
// Get user
return c.JSON(fiber.Map{"message": "Get user", "id": c.Params("id")})
})
userGrp.Post("/", func(c fiber.Ctx) error {
// Create user
return c.JSON(fiber.Map{"message": "User created"})
})
})
})
```

```go
// After
app.Route("/api").Route("/user/:id?")
.Get(func(c fiber.Ctx) error {
// Get user
return c.JSON(fiber.Map{"message": "Get user", "id": c.Params("id")})
})
.Post(func(c fiber.Ctx) error {
// Create user
return c.JSON(fiber.Map{"message": "User created"})
});
```

### 🧠 Context

### 📎 Parser
Expand Down Expand Up @@ -387,4 +432,4 @@ app.Use(static.New("", static.Config{
IndexNames: []string{"index.html"},
MaxAge: 3600,
}))
```
```

0 comments on commit e561026

Please sign in to comment.