Skip to content

Commit 5f57189

Browse files
Add docs from gofiber/fiber@3646c82
1 parent 647caf9 commit 5f57189

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

docs/core/guide/advance-format.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
id: advance-format
3-
title: 🐛 Advance Format
3+
title: 🐛 Advanced Format
44
description: >-
55
Learn how to use MessagePack (MsgPack) and CBOR for efficient binary serialization in Fiber applications.
66
sidebar_position: 9
77
---
88

9-
## Msgpack
9+
## MsgPack
1010

1111
Fiber enables efficient binary serialization using MessagePack (MsgPack). You can leverage popular Go libraries to encode and decode MsgPack data within your route handlers.
1212

1313
- 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).
1515

1616
### Recommended Libraries
1717

@@ -56,7 +56,7 @@ func main() {
5656
return err
5757
}
5858
// Content type will be set automatically to application/vnd.msgpack
59-
return c.MsgPack(data)
59+
return c.MsgPack(user)
6060
})
6161

6262
app.Listen(":3000")
@@ -65,9 +65,9 @@ func main() {
6565

6666
## CBOR
6767

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).
6969

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).
7171

7272
```bash
7373
go get github.com/fxamacker/cbor/v2

docs/core/guide/error-handling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import TabItem from '@theme/TabItem';
1313

1414
## Catching Errors
1515

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.
1717

1818
<Tabs>
1919
<TabItem value="example" label="Example">
@@ -53,7 +53,7 @@ func main() {
5353
}
5454
```
5555

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`).
5757

5858
```go title="Example"
5959
app.Get("/", func(c fiber.Ctx) error {
@@ -93,7 +93,7 @@ var DefaultErrorHandler = func(c fiber.Ctx, err error) error {
9393

9494
A custom error handler can be set using a [Config](../api/fiber.md#errorhandler) when initializing a [Fiber instance](../api/fiber.md#new).
9595

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.
9797

9898
The following example shows how to display error pages for different types of errors.
9999

docs/core/guide/faster-fiber.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar_position: 7
66

77
## Custom JSON Encoder/Decoder
88

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:
1010

1111
- [goccy/go-json](https://github.com/goccy/go-json)
1212
- [bytedance/sonic](https://github.com/bytedance/sonic)
@@ -25,7 +25,7 @@ func main() {
2525
JSONDecoder: json.Unmarshal,
2626
})
2727

28-
# ...
28+
// ...
2929
}
3030
```
3131

docs/core/guide/grouping.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ sidebar_position: 2
55
---
66

77
:::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.
99
:::
1010

1111
## Paths
1212

13-
Like `Routing`, groups can also have paths that belong to a cluster.
13+
Groups can use path prefixes to organize related routes.
1414

1515
```go
1616
func main() {
@@ -30,7 +30,7 @@ func main() {
3030
}
3131
```
3232

33-
A **Group** of paths can have an optional handler.
33+
A group of paths can include an optional handler.
3434

3535
```go
3636
func main() {
@@ -51,12 +51,12 @@ func main() {
5151
```
5252

5353
:::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.
5555
:::
5656

5757
## Group Handlers
5858

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.
6060

6161
```go
6262
func main() {

docs/core/guide/templates.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ type Views interface {
5252
Load() error
5353

5454
// Outputs a template to the provided buffer using the provided template,
55-
// template name, and binded data
55+
// template name, and bound data
5656
Render(io.Writer, string, interface{}, ...string) error
5757
}
5858
```
5959

6060
:::note
61-
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.
6262
:::
6363

6464
## Rendering Templates
6565

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.
6767

6868
```go title="Signature"
6969
func (c Ctx) Render(name string, bind Map, layouts ...string) error

docs/core/intro.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ id: welcome
44
title: 👋 Welcome
55
sidebar_position: 1
66
---
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!
88

99
**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**.
1010

@@ -16,15 +16,15 @@ Looking to practice Fiber concepts hands-on? Check out our [Learning Resources](
1616

1717
First, [download](https://go.dev/dl/) and install Go. Version `1.25` or higher is required.
1818

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:
2020

2121
```bash
2222
go get github.com/gofiber/fiber/v3
2323
```
2424

2525
### Zero Allocation
2626

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:
2828

2929
```go
3030
func handler(c fiber.Ctx) error {
@@ -75,7 +75,7 @@ For more information, please refer to [#426](https://github.com/gofiber/fiber/is
7575

7676
### Hello, World
7777

78-
Below is the most straightforward **Fiber** application you can create:
78+
Here is the simplest **Fiber** application you can create:
7979

8080
```go
8181
package main
@@ -101,7 +101,7 @@ Browse to `http://localhost:3000` and you should see `Hello, World!` displayed o
101101

102102
### Basic Routing
103103

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.).
105105

106106
Each route can have **multiple handler functions** that are executed when the route is matched.
107107

0 commit comments

Comments
 (0)