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/core/guide/advance-format.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
---
2
2
id: advance-format
3
-
title: 🐛 Advance Format
3
+
title: 🐛 Advanced Format
4
4
description: >-
5
5
Learn how to use MessagePack (MsgPack) and CBOR for efficient binary serialization in Fiber applications.
6
6
sidebar_position: 9
7
7
---
8
8
9
-
## Msgpack
9
+
## MsgPack
10
10
11
11
Fiber enables efficient binary serialization using MessagePack (MsgPack). You can leverage popular Go libraries to encode and decode MsgPack data within your route handlers.
12
12
13
13
- Fiber supports binding requests with the `application/vnd.msgpack` content type by default. For more details, see the [Binding documentation](../api/bind.md#msgpack).
14
-
- Use `Ctx.MsgPack()` to bind MsgPack data directly to structs, similar to how you would use JSON binding. Alternatively, use `Ctx.AutoFormat()` to send response as MsgPack when the Accept HTTP header is `application/vnd.msgpack`, For more details, see the [AutoFormat documentation](../api/ctx.md#autoformat).
14
+
- Use `Bind().MsgPack()` to bind MsgPack data directly to structs, similar to how you would use JSON binding. Alternatively, use `Ctx.AutoFormat()` to send the response as MsgPack when the `Accept` HTTP header is `application/vnd.msgpack`. For more details, see the [AutoFormat documentation](../api/ctx.md#autoformat).
15
15
16
16
### Recommended Libraries
17
17
@@ -56,7 +56,7 @@ func main() {
56
56
return err
57
57
}
58
58
// Content type will be set automatically to application/vnd.msgpack
59
-
return c.MsgPack(data)
59
+
return c.MsgPack(user)
60
60
})
61
61
62
62
app.Listen(":3000")
@@ -65,9 +65,9 @@ func main() {
65
65
66
66
## CBOR
67
67
68
-
Fiber doesn't include a CBOR implementation by default. To enable CBOR encoding and decoding you need to choose a library, for example[fxamacker/cbor](https://github.com/fxamacker/cbor).
68
+
Fiber doesn't include a CBOR implementation by default. To enable CBOR encoding and decoding, choose a library such as[fxamacker/cbor](https://github.com/fxamacker/cbor).
69
69
70
-
- Use `Ctx.CBOR()` to bind CBOR data directly to structs, similar to how you would use JSON binding. Alternatively, use `Ctx.AutoFormat()` to send response as CBOR when the Accept HTTP header is `application/cbor`. For more details, see the [AutoFormat documentation](../api/ctx.md#autoformat).
70
+
- Use `Bind().CBOR()` to bind CBOR data directly to structs, similar to how you would use JSON binding. Alternatively, use `Ctx.AutoFormat()` to send the response as CBOR when the `Accept` HTTP header is `application/cbor`. For more details, see the [AutoFormat documentation](../api/ctx.md#autoformat).
Copy file name to clipboardExpand all lines: docs/core/guide/error-handling.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ import TabItem from '@theme/TabItem';
13
13
14
14
## Catching Errors
15
15
16
-
It’s essential to ensure that Fiber catches all errors that occur while running route handlers and middleware. You must return them to the handler function, where Fiber will catch and process them.
16
+
Ensure that Fiber catches all errors from route handlers and middleware by returning them to the handler function for processing.
17
17
18
18
<Tabs>
19
19
<TabItemvalue="example"label="Example">
@@ -53,7 +53,7 @@ func main() {
53
53
}
54
54
```
55
55
56
-
You could use Fiber's custom error struct to pass an additional `status code` using`fiber.NewError()`. It's optional to pass a message; if this is left empty, it will default to the status code message \(`404`equals`Not Found`\).
56
+
Use Fiber's custom error struct to pass a status code with`fiber.NewError()`. The message parameter is optional; if omitted, it defaults to the standard status text (for example, `404`becomes`Not Found`).
A custom error handler can be set using a [Config](../api/fiber.md#errorhandler) when initializing a [Fiber instance](../api/fiber.md#new).
95
95
96
-
In most cases, the default error handler should be sufficient. However, a custom error handler can come in handy if you want to capture different types of errors and take action accordingly e.g., send a notification email or log an error to the centralized system. You can also send customized responses to the client e.g., error page or just a JSON response.
96
+
In most cases, the default error handler is sufficient. However, a custom handler is useful when you need to capture different error types and respond accordingly—for example, sending notification emails or logging to a centralized system. You can also send custom responses to the client, such as an error page or a JSON message.
97
97
98
98
The following example shows how to display error pages for different types of errors.
Copy file name to clipboardExpand all lines: docs/core/guide/faster-fiber.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ sidebar_position: 7
6
6
7
7
## Custom JSON Encoder/Decoder
8
8
9
-
Since Fiber v2.32.0, we have adopted `encoding/json` as the default JSON library for its stability and reliability. However, the standard library can be slower than some third-party alternatives. If you find the performance of `encoding/json`unsatisfactory, we suggest considering these libraries:
9
+
Since Fiber v2.32.0, we have adopted `encoding/json` as the default JSON library for its stability and reliability. However, the standard library can be slower than some third-party alternatives. If its performance is unsatisfactory, consider the following libraries:
Copy file name to clipboardExpand all lines: docs/core/guide/grouping.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,12 @@ sidebar_position: 2
5
5
---
6
6
7
7
:::info
8
-
In general, the Group functionality in Fiber behaves similarly to ExpressJS. Groups are declared virtually and all routes declared within the group are flattened into a single list with a prefix, which is then checked by the framework in the order it was declared. This means that the behavior of Group in Fiber is identical to that of ExpressJS.
8
+
In general, group functionality in Fiber behaves like Express.js. Groups are declared virtually, and all routes defined within a group are flattened into a single list with a prefix and processed in the order declared. This makes group behavior in Fiber identical to Express.js.
9
9
:::
10
10
11
11
## Paths
12
12
13
-
Like `Routing`, groups can also have paths that belong to a cluster.
13
+
Groups can use path prefixes to organize related routes.
14
14
15
15
```go
16
16
funcmain() {
@@ -30,7 +30,7 @@ func main() {
30
30
}
31
31
```
32
32
33
-
A **Group** of paths can have an optional handler.
33
+
A group of paths can include an optional handler.
34
34
35
35
```go
36
36
funcmain() {
@@ -51,12 +51,12 @@ func main() {
51
51
```
52
52
53
53
:::caution
54
-
Running **/api**, **/v1** or **/v2** will result in **404** error, make sure you have the errors set.
54
+
Accessing `/api`, `/v1`, or `/v2` directly results in a **404** error, so configure appropriate error handlers.
55
55
:::
56
56
57
57
## Group Handlers
58
58
59
-
Group handlers can also be used as a routing path but they must have **Next** added to them so that the flow can continue.
59
+
Group handlers can also act as routing paths, but they must call `Next`to continue the flow.
The `Render` method is linked to the [**ctx.Render\(\)**](../api/ctx.md#render) function that accepts a template name and binding data.
61
+
The `Render` method powers the [**ctx.Render\(\)**](../api/ctx.md#render) function, which accepts a template name and data to bind.
62
62
:::
63
63
64
64
## Rendering Templates
65
65
66
-
Once an engine is set up, a route handler can call the [**ctx.Render\(\)**](../api/ctx.md#render) function with a template name and binded data to send the rendered template.
66
+
Once an engine is set up, a route handler can call the [**ctx.Render\(\)**](../api/ctx.md#render) function with a template name and bound data to send the rendered template.
Copy file name to clipboardExpand all lines: docs/core/intro.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ id: welcome
4
4
title: 👋 Welcome
5
5
sidebar_position: 1
6
6
---
7
-
Welcome to the online API documentation for Fiber, complete with examples to help you start building web applications with Fiber right away!
7
+
Welcome to Fiber's online API documentation, complete with examples to help you start building web applications right away!
8
8
9
9
**Fiber** is an [Express](https://github.com/expressjs/express)-inspired **web framework** built on top of [Fasthttp](https://github.com/valyala/fasthttp), the **fastest** HTTP engine for [Go](https://go.dev/doc/). It is designed to facilitate rapid development with **zero memory allocations** and a strong focus on **performance**.
10
10
@@ -16,15 +16,15 @@ Looking to practice Fiber concepts hands-on? Check out our [Learning Resources](
16
16
17
17
First, [download](https://go.dev/dl/) and install Go. Version `1.25` or higher is required.
18
18
19
-
Installation is done using the [`go get`](https://pkg.go.dev/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) command:
19
+
Install Fiber using the [`go get`](https://pkg.go.dev/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) command:
20
20
21
21
```bash
22
22
go get github.com/gofiber/fiber/v3
23
23
```
24
24
25
25
### Zero Allocation
26
26
27
-
Fiber is optimized for **high performance**, meaning values returned from **fiber.Ctx** are **not** immutable by default and **will** be reused across requests. As a rule of thumb, you **must** only use context values within the handler and **must not** keep any references. Once you return from the handler, any values obtained from the context will be reused in future requests. Here is an example:
27
+
Fiber is optimized for **high performance**, meaning values returned from **fiber.Ctx** are **not** immutable by default and **will** be reused across requests. As a rule of thumb, you should use context values only within the handler and **must not** keep any references. Once you return from the handler, any values obtained from the context will be reused in future requests. Here is an example:
28
28
29
29
```go
30
30
funchandler(cfiber.Ctx) error {
@@ -75,7 +75,7 @@ For more information, please refer to [#426](https://github.com/gofiber/fiber/is
75
75
76
76
### Hello, World
77
77
78
-
Below is the most straightforward**Fiber** application you can create:
78
+
Here is the simplest**Fiber** application you can create:
79
79
80
80
```go
81
81
package main
@@ -101,7 +101,7 @@ Browse to `http://localhost:3000` and you should see `Hello, World!` displayed o
101
101
102
102
### Basic Routing
103
103
104
-
Routing determines how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (`GET`, `PUT`, `POST`, etc.).
104
+
Routing determines how an application responds to a client request at a particular endpoint—a combination of path and HTTP request method (`GET`, `PUT`, `POST`, etc.).
105
105
106
106
Each route can have **multiple handler functions** that are executed when the route is matched.
0 commit comments