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/intro.md
+35-28Lines changed: 35 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@ id: welcome
4
4
title: 👋 Welcome
5
5
sidebar_position: 1
6
6
---
7
-
An online API documentation with examples so you can start building web apps with Fiber right away!
7
+
Welcome to the online API documentation for Fiber, complete with examples to help you start building web applications with Fiber right away!
8
8
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/). Designed to **ease** things up for **fast**development with **zero memory allocation** and **performance** in mind.
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
11
-
These docs are for **Fiber v3**, which was released on **March XX, 2024**.
11
+
These docs are for **Fiber v3**, which was released on **Month xx, 202x**.
12
12
13
13
### Installation
14
14
15
-
First of all, [download](https://go.dev/dl/) and install Go. `1.22` or higher is required.
15
+
First, [download](https://go.dev/dl/) and install Go. Version`1.22` or higher is required.
16
16
17
17
Installation is done using the [`go get`](https://pkg.go.dev/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) command:
18
18
@@ -22,7 +22,7 @@ go get github.com/gofiber/fiber/v3
22
22
23
23
### Zero Allocation
24
24
25
-
Fiber is optimized for **high-performance**, meaning values returned from **fiber.Ctx** are **not** immutable by default and **will** be re-used 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 re-used in future requests. Here is an example:
25
+
Fiber is optimized for **highperformance**, 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:
Alternatively, you can also use the `Immutable` setting. It will make all values returned from the context immutable, allowing you to persist them anywhere. Of course, this comes at the cost of performance.
64
+
Alternatively, you can enable the `Immutable` setting. This makes all values returned from the context immutable, allowing you to persist them anywhere. Note that this comes at the cost of performance.
65
65
66
66
```go
67
67
app:= fiber.New(fiber.Config{
68
68
Immutable: true,
69
69
})
70
70
```
71
71
72
-
For more information, please check [**\#426**](https://github.com/gofiber/fiber/issues/426), [**\#185**](https://github.com/gofiber/fiber/issues/185) and [**\#3012**](https://github.com/gofiber/fiber/issues/3012).
72
+
For more information, please refer to [#426](https://github.com/gofiber/fiber/issues/426), [#185](https://github.com/gofiber/fiber/issues/185), and [#3012](https://github.com/gofiber/fiber/issues/3012).
73
73
74
74
### Hello, World
75
75
76
-
Embedded below is essentially the most straightforward **Fiber**app you can create:
76
+
Below is the most straightforward **Fiber**application you can create:
77
77
78
78
```go
79
79
package main
@@ -95,15 +95,15 @@ func main() {
95
95
go run server.go
96
96
```
97
97
98
-
Browse to `http://localhost:3000` and you should see `Hello, World!` on the page.
98
+
Browse to `http://localhost:3000` and you should see `Hello, World!`displayed on the page.
99
99
100
-
### Basic routing
100
+
### Basic Routing
101
101
102
-
Routing refers to determining 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.).
102
+
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.).
103
103
104
104
Each route can have **multiple handler functions** that are executed when the route is matched.
To serve static files such as **images**, **CSS**, and **JavaScript** files, replace your function handler with a file or directory string.
166
-
You can check out [static middleware](./middleware/static.md) for more information.
167
-
Function signature:
166
+
To serve static files such as **images**, **CSS**, and **JavaScript** files, use the `Static` method with a directory path. For more information, refer to the [static middleware](./middleware/static.md).
168
167
169
168
Use the following code to serve files in a directory named `./public`:
170
169
171
170
```go
172
-
app:= fiber.New()
171
+
package main
172
+
173
+
import (
174
+
"github.com/gofiber/fiber/v3"
175
+
)
173
176
174
-
app.Get("/*", static.New("./public"))
177
+
funcmain() {
178
+
app:= fiber.New()
175
179
176
-
app.Listen(":3000")
180
+
app.Static("/", "./public")
181
+
182
+
app.Listen(":3000")
183
+
}
177
184
```
178
185
179
-
Now, you can load the files that are in the `./public` directory:
186
+
Now, you can access the files in the `./public` directory via your browser:
0 commit comments