Skip to content

Commit 3604afc

Browse files
📒 docs: Full audit of documentation (#3717)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 82a8485 commit 3604afc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+567
-552
lines changed

docs/addon/retry.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ id: retry
44

55
# Retry Addon
66

7-
Retry addon for [Fiber](https://github.com/gofiber/fiber) designed to apply retry mechanism for unsuccessful network
8-
operations. This addon uses an exponential backoff algorithm with jitter. It calls the function multiple times and tries
9-
to make it successful. If all calls are failed, then, it returns an error. It adds a jitter at each retry step because adding
10-
a jitter is a way to break synchronization across the client and avoid collision.
7+
The Retry addon for [Fiber](https://github.com/gofiber/fiber) retries failed network operations using exponential
8+
backoff with jitter. It repeatedly invokes a function until it succeeds or the maximum number of attempts is
9+
exhausted. Jitter at each step breaks client synchronization and helps avoid collisions. If all attempts fail, the
10+
addon returns an error.
1111

1212
## Table of Contents
1313

14-
- [Retry Addon](#retry-addon)
15-
- [Table of Contents](#table-of-contents)
1614
- [Signatures](#signatures)
1715
- [Examples](#examples)
1816
- [Default Config](#default-config)
@@ -41,19 +39,19 @@ import (
4139
func main() {
4240
expBackoff := retry.NewExponentialBackoff(retry.Config{})
4341

44-
// Local variables that will be used inside of Retry
42+
// Local variables used inside Retry
4543
var resp *client.Response
4644
var err error
4745

48-
// Retry a network request and return an error to signify to try again
46+
// Retry a network request and return an error to signal another attempt
4947
err = expBackoff.Retry(func() error {
5048
client := client.New()
5149
resp, err = client.Get("https://gofiber.io")
5250
if err != nil {
5351
return fmt.Errorf("GET gofiber.io failed: %w", err)
5452
}
5553
if resp.StatusCode() != 200 {
56-
return fmt.Errorf("GET gofiber.io did not return OK 200")
54+
return fmt.Errorf("GET gofiber.io did not return 200 OK")
5755
}
5856
return nil
5957
})

docs/api/app.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: app
33
title: 🚀 App
4-
description: The app instance conventionally denotes the Fiber application.
4+
description: The `App` type represents your Fiber application.
55
sidebar_position: 2
66
---
77

@@ -35,7 +35,7 @@ import RoutingHandler from './../partials/routing/handler.md';
3535

3636
### Mounting
3737

38-
You can mount a Fiber instance using the [`app.Use`](./app.md#use) method, similar to [`Express`](https://expressjs.com/en/api.html#router.use).
38+
Mount another Fiber instance with [`app.Use`](./app.md#use), similar to Express's [`router.use`](https://expressjs.com/en/api.html#router.use).
3939

4040
```go title="Example"
4141
package main
@@ -219,15 +219,15 @@ func main() {
219219

220220
### HandlersCount
221221

222-
This method returns the number of registered handlers.
222+
Returns the number of registered handlers.
223223

224224
```go title="Signature"
225225
func (app *App) HandlersCount() uint32
226226
```
227227

228228
### Stack
229229

230-
This method returns the original router stack.
230+
Returns the underlying router stack.
231231

232232
```go title="Signature"
233233
func (app *App) Stack() [][]*Route

docs/api/bind.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ sidebar_position: 4
66
toc_max_heading_level: 4
77
---
88

9-
Bindings are used to parse the request/response body, query parameters, cookies, and much more into a struct.
9+
Bindings parse request and response bodies, query parameters, cookies, and more into structs.
1010

1111
:::info
12-
All binder returned values are only valid within the handler. Do not store any references.
13-
Make copies or use the [**`Immutable`**](./ctx.md) setting instead. [Read more...](../#zero-allocation)
12+
Binder-returned values are valid only within the handler. To keep them, copy the data
13+
or enable the [**`Immutable`**](./ctx.md) setting. [Read more...](../#zero-allocation)
1414
:::
1515

1616
## Binders
@@ -30,7 +30,7 @@ Make copies or use the [**`Immutable`**](./ctx.md) setting instead. [Read more..
3030

3131
### All
3232

33-
The `All` function binds data from various sources (URL parameters, request body, query parameters, headers, and cookies) into the provided struct pointer `out`. It processes each source in a predefined order, applying data to the struct fields based on their tags.
33+
The `All` function binds data from URL parameters, the request body, query parameters, headers, and cookies into `out`. Sources are applied in the following order using struct field tags.
3434

3535
#### Precedence Order
3636

@@ -71,7 +71,7 @@ app.Post("/users", func(c fiber.Ctx) error {
7171

7272
Binds the request body to a struct.
7373

74-
It is important to specify the correct struct tag based on the content type to be parsed. For example, if you want to parse a JSON body with a field called `Pass`, you would use a struct field with `json:"pass"`.
74+
Use tags that match the content type. For example, to parse a JSON body with a `Pass` field, declare `json:"pass"`.
7575

7676
| Content-Type | Struct Tag |
7777
| ----------------------------------- | ---------- |
@@ -106,7 +106,7 @@ app.Post("/", func(c fiber.Ctx) error {
106106
})
107107
```
108108

109-
Run tests with the following `curl` commands:
109+
Test the handler with these `curl` commands:
110110

111111
```bash
112112
# JSON
@@ -158,7 +158,7 @@ app.Post("/", func(c fiber.Ctx) error {
158158
})
159159
```
160160

161-
Run tests with the following `curl` command:
161+
Test the defaults with this `curl` command:
162162

163163
```bash
164164
curl -X POST -H "Content-Type: application/cbor" --data "\xa2dnamedjohndpasscdoe" localhost:3000

docs/api/constants.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
id: constants
33
title: 📋 Constants
4-
description: Some constants for Fiber.
4+
description: Core HTTP constants used throughout Fiber.
55
sidebar_position: 10
66
---
77

8-
### HTTP methods were copied from net/http
8+
### HTTP methods (mirrors `net/http`)
99

1010
```go
1111
const (
@@ -22,7 +22,7 @@ const (
2222
)
2323
```
2424

25-
### MIME types that are commonly used
25+
### Common MIME types
2626

2727
```go
2828
const (
@@ -48,7 +48,7 @@ const (
4848
)
4949
```
5050

51-
### HTTP status codes were copied from net/http
51+
### HTTP status codes (mirrors `net/http`)
5252

5353
```go
5454
const (

docs/api/ctx.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ app.Get("/stack", func(c fiber.Ctx) error {
2424

2525
### Bind
2626

27-
Bind is a method that supports bindings for the request/response body, query parameters, URL parameters, cookies, and much more.
28-
It returns a pointer to the [Bind](./bind.md) struct which contains all the methods to bind the request/response data.
27+
Bind returns a helper for decoding the request body, query string, headers, cookies, and more.
2928

30-
For detailed information, check the [Bind](./bind.md) documentation.
29+
For full details, see the [Bind](./bind.md) documentation.
3130

3231
```go title="Signature"
3332
func (c fiber.Ctx) Bind() *Bind
@@ -97,14 +96,14 @@ app.Get("/", func(c fiber.Ctx) error {
9796

9897
### GetReqHeaders
9998

100-
Returns the HTTP request headers as a map. Since a header can be set multiple times in a single request, the values of the map are slices of strings containing all the different values of the header.
99+
Returns the HTTP request headers as a map. Because a header can appear multiple times in a request, each key maps to a slice with all values for that header.
101100

102101
```go title="Signature"
103102
func (c fiber.Ctx) GetReqHeaders() map[string][]string
104103
```
105104

106105
:::info
107-
Returned value is only valid within the handler. Do not store any references.
106+
The returned value is valid only within the handler. Do not store references.
108107
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
109108
:::
110109

@@ -130,7 +129,7 @@ app.Get("/", func(c fiber.Ctx) error {
130129
```
131130

132131
:::info
133-
Returned value is only valid within the handler. Do not store any references.
132+
The returned value is valid only within the handler. Do not store references.
134133
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
135134
:::
136135

@@ -143,7 +142,7 @@ func (c fiber.Ctx) GetRespHeaders() map[string][]string
143142
```
144143

145144
:::info
146-
Returned value is only valid within the handler. Do not store any references.
145+
The returned value is valid only within the handler. Do not store references.
147146
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
148147
:::
149148

@@ -174,7 +173,7 @@ app.Get("/test", func(c fiber.Ctx) error {
174173

175174
### Locals
176175

177-
A method that stores variables scoped to the request and, therefore, are available only to the routes that match the request. The stored variables are removed after the request is handled. If any of the stored data implements the `io.Closer` interface, its `Close` method will be called before it's removed.
176+
Stores variables scoped to the request, making them available only to matching routes. The variables are removed after the request completes. If a stored value implements `io.Closer`, Fiber calls its `Close` method before removal.
178177

179178
:::tip
180179
This is useful if you want to pass some **specific** data to the next middleware. Remember to perform type assertions when retrieving the data to ensure it is of the expected type. You can also use a non-exported type as a key to avoid collisions.
@@ -565,7 +564,7 @@ app.Post("/", func(c fiber.Ctx) error {
565564
```
566565

567566
:::info
568-
Returned value is only valid within the handler. Do not store any references.
567+
The returned value is valid only within the handler. Do not store references.
569568
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
570569
:::
571570

@@ -587,14 +586,14 @@ app.Post("/", func(c fiber.Ctx) error {
587586
```
588587

589588
:::info
590-
Returned value is only valid within the handler. Do not store any references.
589+
The returned value is valid only within the handler. Do not store references.
591590
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
592591
:::
593592

594593
### ClientHelloInfo
595594

596-
`ClientHelloInfo` contains information from a ClientHello message in order to guide application logic in the `GetCertificate` and `GetConfigForClient` callbacks.
597-
You can refer to the [ClientHelloInfo](https://golang.org/pkg/crypto/tls/#ClientHelloInfo) struct documentation for more information on the returned struct.
595+
`ClientHelloInfo` contains information from a ClientHello message to guide application logic in the `GetCertificate` and `GetConfigForClient` callbacks.
596+
Refer to the [ClientHelloInfo](https://golang.org/pkg/crypto/tls/#ClientHelloInfo) struct documentation for details on the returned struct.
598597

599598
```go title="Signature"
600599
func (c fiber.Ctx) ClientHelloInfo() *tls.ClientHelloInfo
@@ -626,7 +625,7 @@ app.Get("/", func(c fiber.Ctx) error {
626625
```
627626

628627
:::info
629-
Returned value is only valid within the handler. Do not store any references.
628+
The returned value is valid only within the handler. Do not store references.
630629
Use [`App.GetString`](./app.md#getstring) or [`App.GetBytes`](./app.md#getbytes) when immutability is enabled, or manually copy values (for example with [`utils.CopyString`](https://github.com/gofiber/utils) / `utils.CopyBytes`) when it's disabled. [Read more...](../#zero-allocation)
631630
:::
632631

@@ -668,7 +667,7 @@ app.Post("/", func(c fiber.Ctx) error {
668667

669668
:::info
670669

671-
Returned value is only valid within the handler. Do not store any references.
670+
The returned value is valid only within the handler. Do not store references.
672671
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
673672

674673
:::
@@ -707,7 +706,7 @@ app.Get("/", func(c fiber.Ctx) error {
707706
```
708707

709708
:::info
710-
Returned value is only valid within the handler. Do not store any references.
709+
The returned value is valid only within the handler. Do not store references.
711710
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
712711
:::
713712

@@ -733,7 +732,7 @@ app.Get("/", func(c fiber.Ctx) error {
733732
```
734733

735734
:::info
736-
Returned value is only valid within the handler. Do not store any references.
735+
The returned value is valid only within the handler. Do not store references.
737736
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
738737
:::
739738

@@ -756,7 +755,7 @@ app.Get("/", func(c fiber.Ctx) error {
756755
```
757756

758757
:::info
759-
Returned value is only valid within the handler. Do not store any references.
758+
The returned value is valid only within the handler. Do not store references.
760759
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
761760
:::
762761

@@ -954,7 +953,7 @@ app.Get("/", func(c fiber.Ctx) error {
954953
```
955954

956955
:::info
957-
Returned value is only valid within the handler. Do not store any references.
956+
The returned value is valid only within the handler. Do not store references.
958957
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
959958
:::
960959

@@ -1005,7 +1004,7 @@ app.Get("/v1/*/shop/*", func(c fiber.Ctx) error {
10051004
```
10061005

10071006
:::info
1008-
Returned value is only valid within the handler. Do not store any references.
1007+
The returned value is valid only within the handler. Do not store references.
10091008
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
10101009
:::
10111010

@@ -1182,7 +1181,7 @@ app.Get("/", func(c fiber.Ctx) error {
11821181
```
11831182

11841183
:::info
1185-
Returned value is only valid within the handler. Do not store any references.
1184+
The returned value is valid only within the handler. Do not store references.
11861185
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
11871186
:::
11881187

0 commit comments

Comments
 (0)