Skip to content

Commit

Permalink
Update Ctxt docs and What's new
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby authored Nov 12, 2024
1 parent 12daef3 commit 022d3c7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
48 changes: 24 additions & 24 deletions docs/api/ctx.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,20 @@ app.Get("/hello", func(c fiber.Ctx) error {

## Context

Returns [\*fasthttp.RequestCtx](https://godoc.org/github.com/valyala/fasthttp#RequestCtx) that is compatible with the context.Context interface that requires a deadline, a cancellation signal, and other values across API boundaries.
Context returns a context implementation that was set by user earlier or returns a non-nil, empty context, if it was not set earlier.

```go title="Signature"
func (c Ctx) Context() *fasthttp.RequestCtx
func (c Ctx) Context() context.Context
```

:::info
Please read the [Fasthttp Documentation](https://pkg.go.dev/github.com/valyala/fasthttp?tab=doc) for more information.
:::
```go title="Example"
app.Get("/", func(c fiber.Ctx) error {
ctx := c.Context()
// ctx is context implementation set by user

// ...
})
```

## Cookie

Expand Down Expand Up @@ -1489,6 +1494,19 @@ app.Get("/", func(c fiber.Ctx) error {
})
```
## RequestCtx
Returns [\*fasthttp.RequestCtx](https://godoc.org/github.com/valyala/fasthttp#RequestCtx) that is compatible with the context.Context interface that requires a deadline, a cancellation signal, and other values across API boundaries.
```go title="Signature"
func (c Ctx) RequestCtx() *fasthttp.RequestCtx
```
:::info
Please read the [Fasthttp Documentation](https://pkg.go.dev/github.com/valyala/fasthttp?tab=doc) for more information.
:::

Check failure on line 1509 in docs/api/ctx.md

View workflow job for this annotation

GitHub Actions / markdownlint

Multiple consecutive blank lines

docs/api/ctx.md:1509 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md012.md
## Response
Response return the [\*fasthttp.Response](https://godoc.org/github.com/valyala/fasthttp#Response) pointer
Expand Down Expand Up @@ -1893,7 +1911,7 @@ app.Get("/", func(c fiber.Ctx) error {

## SetContext

Sets the user specified implementation for context interface.
Sets the user specified implementation for context.Context interface.

```go title="Signature"
func (c Ctx) SetContext(ctx context.Context)
Expand Down Expand Up @@ -2005,24 +2023,6 @@ app.Get("/", func(c fiber.Ctx) error {
})
```

## Context

Context returns a context implementation that was set by user earlier
or returns a non-nil, empty context, if it was not set earlier.

```go title="Signature"
func (c Ctx) Context() context.Context
```

```go title="Example"
app.Get("/", func(c fiber.Ctx) error {
ctx := c.Context()
// ctx is context implementation set by user
// ...
})
```

## Vary

Adds the given header field to the [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) response header. This will append the header, if not already listed, otherwise leaves it listed in the current location.
Expand Down
3 changes: 3 additions & 0 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ DRAFT section
- Format -> Param: body interface{} -> handlers ...ResFmt
- Redirect -> c.Redirect().To()
- SendFile now supports different configurations using the config parameter.
- Context has been renamed to RequestCtx which corresponds to the FastHTTP Request Context.
- UserContext has been renamed to Context which returns a context.Context object.
- SetUserContext has been renamed to SetContext.

---

Expand Down

0 comments on commit 022d3c7

Please sign in to comment.