Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions docs/api/ctx.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Media-Type parameters are supported.
app.Get("/", func(c *fiber.Ctx) error {
// Extra parameters in the accept are ignored
c.Accepts("text/plain;format=flowed") // "text/plain;format=flowed"

// An offer must contain all parameters present in the Accept type
c.Accepts("application/json") // ""

Expand Down Expand Up @@ -239,7 +239,7 @@ app.Post("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## Body
Expand All @@ -259,7 +259,7 @@ app.Post("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## BodyParser
Expand Down Expand Up @@ -319,7 +319,7 @@ app.Post("/", func(c *fiber.Ctx) error {
// curl -X POST "http://localhost:3000/?name=john&pass=doe"
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## ClearCookie
Expand Down Expand Up @@ -489,7 +489,7 @@ app.Get("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## Download
Expand Down Expand Up @@ -579,7 +579,7 @@ app.Post("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## Fresh
Expand Down Expand Up @@ -615,7 +615,7 @@ app.Get("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## GetReqHeaders
Expand All @@ -626,7 +626,7 @@ Returns the HTTP request headers as a map. Since a header can be set multiple ti
func (c *Ctx) GetReqHeaders() map[string][]string
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## GetRespHeader
Expand All @@ -650,7 +650,7 @@ app.Get("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## GetRespHeaders
Expand All @@ -661,7 +661,7 @@ Returns the HTTP response headers as a map. Since a header can be set multiple t
func (c *Ctx) GetRespHeaders() map[string][]string
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## GetRouteURL
Expand Down Expand Up @@ -707,7 +707,7 @@ app.Get("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## IP
Expand Down Expand Up @@ -954,7 +954,7 @@ app.Post("/", func(c *fiber.Ctx) error {

## Method

Returns a string corresponding to the HTTP method of the request: `GET`, `POST`, `PUT`, and so on.
Returns a string corresponding to the HTTP method of the request: `GET`, `POST`, `PUT`, and so on.
Optionally, you could override the method by passing a string.

```go title="Signature"
Expand Down Expand Up @@ -1054,7 +1054,7 @@ app.Get("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## Params
Expand Down Expand Up @@ -1103,7 +1103,7 @@ app.Get("/v1/*/shop/*", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## ParamsInt
Expand Down Expand Up @@ -1280,7 +1280,7 @@ app.Get("/", func(c *fiber.Ctx) error {
})
```

> _Returned value is only valid within the handler. Do not store any references.
> _Returned value is only valid within the handler. Do not store any references.
> Make copies or use the_ [_**`Immutable`**_](ctx.md) _setting instead._ [_Read more..._](../#zero-allocation)

## QueryBool
Expand Down Expand Up @@ -1402,7 +1402,7 @@ app.Get("/", func(c *fiber.Ctx) error {
log.Println(p.Products) // ["shoe,hat"]
// fiber.Config{EnableSplittingOnParsers: true}
// log.Println(p.Products) // ["shoe", "hat"]


// ...
})
Expand Down Expand Up @@ -1442,6 +1442,24 @@ Redirects to the URL derived from the specified path, with specified status, a p

:::info
If **not** specified, status defaults to **302 Found**.

In Fiber v3, the default will change to **303 See Fount** for more predictable
cross-browser behavior.
:::

:::caution
When the redirect status code is **302 Found** (the default in v2), web browsers may change the HTTP method
(for example, converting a POST into a GET) depending on the browser implementation. To ensure that the
original HTTP method is preserved, especially in scenarios where a non-GET method is required, you
should explicitly use one of the following status codes:

- 303 See Other
- 307 Temporary Redirect
- 308 Permanent Redirect

For example, to preserve the HTTP method, use:

`c.Redirect("/new-path", fiber.StatusSeeOther)`
:::

```go title="Signature"
Expand Down
Loading