You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/middleware/timeout.md
+45-43Lines changed: 45 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,16 @@ id: timeout
4
4
5
5
# Timeout
6
6
7
-
There exist two distinct implementations of timeout middleware [Fiber](https://github.com/gofiber/fiber).
7
+
The timeout middleware limits how long a handler can take to complete. When the
8
+
deadline is exceeded, Fiber responds with `408 Request Timeout`. The middleware
9
+
uses `context.WithTimeout` and makes the context available through
10
+
`c.Context()` so that your code can listen for cancellation.
8
11
9
-
## New
10
-
11
-
As a `fiber.Handler` wrapper, it creates a context with `context.WithTimeout` which is then used with `c.Context()`.
12
-
13
-
If the context passed executions (eg. DB ops, Http calls) takes longer than the given duration to return, the timeout error is set and forwarded to the centralized `ErrorHandler`.
14
-
15
-
It does not cancel long running executions. Underlying executions must handle timeout by using `context.Context` parameter.
12
+
:::caution
13
+
`timeout.New` wraps your final handler and can't be added with `app.Use` or
14
+
used in a middleware chain. Register it per route and avoid calling
15
+
`c.Next()` inside the wrapped handler—doing so will panic.
- Cookie now allows Partitioned cookies for [CHIPS](https://developers.google.com/privacy-sandbox/3pcd/chips) support. CHIPS (Cookies Having Independent Partitioned State) is a feature that improves privacy by allowing cookies to be partitioned by top-level site, mitigating cross-site tracking.
455
453
- Cookie automatic security enforcement: When setting a cookie with `SameSite=None`, Fiber automatically sets `Secure=true` as required by RFC 6265bis and modern browsers (Chrome, Firefox, Safari). This ensures compliance with the "None" SameSite policy. See [Mozilla docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#none) and [Chrome docs](https://developers.google.com/search/blog/2020/01/get-ready-for-new-samesitenone-secure) for details.
456
-
-Context now implements [context.Context](https://pkg.go.dev/context#Context).
454
+
-`Ctx` now implements the [context.Context](https://pkg.go.dev/context#Context) interface, replacing the former `UserContext` helpers.
0 commit comments