Skip to content

Commit af6858f

Browse files
Add docs from gofiber/fiber@d8da941
1 parent af80e5f commit af6858f

8 files changed

Lines changed: 158 additions & 152 deletions

File tree

docs/core/addon/retry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ type Config struct {
107107
//
108108
// Optional. Default: 10
109109
MaxRetryCount int
110+
111+
// currentInterval tracks the current waiting time.
112+
//
113+
// Optional. Default: 1 * time.Second
114+
currentInterval time.Duration
110115
}
111116
```
112117

docs/core/api/constants.md

Lines changed: 90 additions & 86 deletions
Large diffs are not rendered by default.

docs/core/api/ctx.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,11 @@ app.Get("/", func(c fiber.Ctx) error {
15681568

15691569
### Protocol
15701570

1571-
Contains the request protocol string: `http` or `https` for **TLS** requests.
1571+
Returns the HTTP protocol version of the request: `HTTP/1.1` or `HTTP/2`.
1572+
1573+
:::info
1574+
To get the request scheme (`http` or `https`), use [`Scheme`](#scheme) instead.
1575+
:::
15721576

15731577
```go title="Signature"
15741578
func (c fiber.Ctx) Protocol() string
@@ -1578,7 +1582,7 @@ func (c fiber.Ctx) Protocol() string
15781582
// GET http://example.com
15791583

15801584
app.Get("/", func(c fiber.Ctx) error {
1581-
c.Protocol() // "http"
1585+
c.Protocol() // "HTTP/1.1"
15821586

15831587
// ...
15841588
})
@@ -1832,7 +1836,7 @@ app.Post("/", func(c fiber.Ctx) error {
18321836
})
18331837
```
18341838

1835-
### Schema
1839+
### Scheme
18361840

18371841
Contains the request protocol string: `http` or `https` for TLS requests.
18381842

@@ -1841,14 +1845,14 @@ Please use [`Config.TrustProxy`](fiber.md#trustproxy) to prevent header spoofing
18411845
:::
18421846

18431847
```go title="Signature"
1844-
func (c fiber.Ctx) Schema() string
1848+
func (c fiber.Ctx) Scheme() string
18451849
```
18461850

18471851
```go title="Example"
18481852
// GET http://example.com
18491853

18501854
app.Get("/", func(c fiber.Ctx) error {
1851-
c.Schema() // "http"
1855+
c.Scheme() // "http"
18521856

18531857
// ...
18541858
})
@@ -1864,7 +1868,7 @@ func (c fiber.Ctx) Secure() bool
18641868

18651869
```go title="Example"
18661870
// Secure() method is equivalent to:
1867-
c.Protocol() == "https"
1871+
c.Scheme() == "https"
18681872
```
18691873

18701874
### Stale

docs/core/api/redirect.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Similar to [Laravel](https://laravel.com/docs/11.x/redirects#redirecting-with-fl
164164
Retrieve all flash messages. See [With](#with) for details.
165165

166166
```go title="Signature"
167-
func (r *Redirect) Messages() map[string]string
167+
func (r *Redirect) Messages() []FlashMessage
168168
```
169169

170170
```go title="Example"
@@ -179,13 +179,13 @@ app.Get("/", func(c fiber.Ctx) error {
179179
Get a flash message by key; see [With](#with).
180180

181181
```go title="Signature"
182-
func (r *Redirect) Message(key string) *Redirect
182+
func (r *Redirect) Message(key string) FlashMessage
183183
```
184184

185185
```go title="Example"
186186
app.Get("/", func(c fiber.Ctx) error {
187187
message := c.Redirect().Message("status")
188-
return c.SendString(message)
188+
return c.SendString(message.Value)
189189
})
190190
```
191191

@@ -194,7 +194,7 @@ app.Get("/", func(c fiber.Ctx) error {
194194
Retrieve stored input data. See [WithInput](#withinput).
195195

196196
```go title="Signature"
197-
func (r *Redirect) OldInputs() map[string]string
197+
func (r *Redirect) OldInputs() []OldInputData
198198
```
199199

200200
```go title="Example"
@@ -209,13 +209,13 @@ app.Get("/", func(c fiber.Ctx) error {
209209
Get stored input data by key; see [WithInput](#withinput).
210210

211211
```go title="Signature"
212-
func (r *Redirect) OldInput(key string) string
212+
func (r *Redirect) OldInput(key string) OldInputData
213213
```
214214

215215
```go title="Example"
216216
app.Get("/name", func(c fiber.Ctx) error {
217217
oldInput := c.Redirect().OldInput("name")
218-
return c.SendString(oldInput)
218+
return c.SendString(oldInput.Value)
219219
})
220220
```
221221

docs/core/client/request.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,32 @@ This structure is designed to be both flexible and efficient, allowing you to ea
1818

1919
```go
2020
type Request struct {
21-
url string
22-
method string
23-
userAgent string
24-
boundary string
25-
referer string
26-
ctx context.Context
27-
header *Header
28-
params *QueryParam
29-
cookies *Cookie
30-
path *PathParam
21+
ctx context.Context
3122

32-
timeout time.Duration
33-
maxRedirects int
23+
body any
24+
header Header
25+
params QueryParam
26+
cookies Cookie
27+
path PathParam
3428

3529
client *Client
3630

37-
body any
38-
formData *FormData
39-
files []*File
40-
bodyType bodyType
31+
formData FormData
4132

4233
RawRequest *fasthttp.Request
34+
url string
35+
method string
36+
userAgent string
37+
boundary string
38+
referer string
39+
files []*File
40+
41+
timeout time.Duration
42+
maxRedirects int
43+
44+
bodyType bodyType
45+
46+
isPathNormalizingDisabled bool
4347
}
4448
```
4549

docs/core/client/rest.md

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,33 +49,13 @@ See [examples](examples.md) for more detailed usage.
4949

5050
```go
5151
type Client struct {
52-
mu sync.RWMutex
52+
logger log.CommonLogger
53+
transport httpClientTransport
5354

54-
fasthttp *fasthttp.Client
55-
56-
baseURL string
57-
userAgent string
58-
referer string
59-
header *Header
60-
params *QueryParam
61-
cookies *Cookie
62-
path *PathParam
63-
64-
debug bool
65-
66-
timeout time.Duration
67-
68-
// user-defined request hooks
69-
userRequestHooks []RequestHook
70-
71-
// client package-defined request hooks
72-
builtinRequestHooks []RequestHook
73-
74-
// user-defined response hooks
75-
userResponseHooks []ResponseHook
76-
77-
// client package-defined response hooks
78-
builtinResponseHooks []ResponseHook
55+
header *Header
56+
params *QueryParam
57+
cookies *Cookie
58+
path *PathParam
7959

8060
jsonMarshal utils.JSONMarshal
8161
jsonUnmarshal utils.JSONUnmarshal
@@ -84,16 +64,20 @@ type Client struct {
8464
cborMarshal utils.CBORMarshal
8565
cborUnmarshal utils.CBORUnmarshal
8666

87-
cookieJar *CookieJar
88-
89-
// proxy
90-
proxyURL string
91-
92-
// retry
93-
retryConfig *RetryConfig
67+
cookieJar *CookieJar
68+
retryConfig *RetryConfig
69+
baseURL string
70+
userAgent string
71+
referer string
72+
userRequestHooks []RequestHook
73+
builtinRequestHooks []RequestHook
74+
userResponseHooks []ResponseHook
75+
builtinResponseHooks []ResponseHook
9476

95-
// logger
96-
logger log.CommonLogger
77+
timeout time.Duration
78+
mu sync.RWMutex
79+
isDebug bool
80+
isPathNormalizingDisabled bool
9781
}
9882
```
9983

docs/core/extra/internal.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ Fiber provides a comprehensive hook system that allows you to run custom functio
401401
- OnName: Invoked when a route is assigned a name.
402402
- OnGroup: Triggered when a group is created.
403403
- OnListen: Runs when the server starts listening.
404-
- OnShutdown: Called during graceful shutdown.
404+
- OnPreShutdown: Runs before the application shuts down.
405+
- OnPostShutdown: Runs after shutdown and receives the shutdown result.
405406
- OnFork: Invoked when a child process is forked.
406407
- OnMount: Used when a sub‑application is mounted.
407408

@@ -412,15 +413,17 @@ flowchart TD
412413
ON[OnName]
413414
OG[OnGroup]
414415
OL[OnListen]
415-
OS[OnShutdown]
416+
OPRS[OnPreShutdown]
417+
OPOS[OnPostShutdown]
416418
OF[OnFork]
417419
OM[OnMount]
418420
419421
H --> OR
420422
H --> ON
421423
H --> OG
422424
H --> OL
423-
H --> OS
425+
H --> OPRS
426+
H --> OPOS
424427
H --> OF
425428
H --> OM
426429
```

docs/core/middleware/logger.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ Writing to `os.File` is goroutine-safe, but custom streams may require locking t
257257
| TimeZone | `string` | TimeZone can be specified, such as "UTC" and "America/New_York" and "Asia/Chongqing", etc | `"Local"` |
258258
| TimeInterval | `time.Duration` | TimeInterval is the delay before the timestamp is updated. | `500 * time.Millisecond` |
259259
| Stream | `io.Writer` | Stream is a writer where logs are written. | `os.Stdout` |
260+
| TimeDone | `<-chan struct{}` | TimeDone stops the background timestamp updater when it is closed. | `nil` |
261+
| BeforeHandlerFunc | `func(*Config)` | BeforeHandlerFunc runs once before the handler is built, letting you customize colors, template, etc. | `beforeHandlerFunc` |
260262
| LoggerFunc | `func(c fiber.Ctx, data *Data, cfg *Config) error` | Custom logger function for integration with logging libraries (Zerolog, Zap, Logrus, etc). Defaults to Fiber's default logger if not defined. | `see default_logger.go defaultLoggerInstance` |
261263
| DisableColors | `bool` | DisableColors defines if the logs output should be colorized. | `false` |
262264
| ForceColors | `bool` | ForceColors defines if the logs output should be colorized even when the output is not a terminal. | `false` |

0 commit comments

Comments
 (0)