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/api/bind.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,11 @@ sidebar_position: 4
6
6
toc_max_heading_level: 4
7
7
---
8
8
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.
10
10
11
11
:::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)
14
14
:::
15
15
16
16
## Binders
@@ -30,7 +30,7 @@ Make copies or use the [**`Immutable`**](./ctx.md) setting instead. [Read more..
30
30
31
31
### All
32
32
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.
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"`.
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.
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.
178
177
179
178
:::tip
180
179
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.
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.
591
590
Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. [Read more...](../#zero-allocation)
592
591
:::
593
592
594
593
### ClientHelloInfo
595
594
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.
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.
630
629
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)
0 commit comments