Skip to content

Commit 35b05f4

Browse files
Fennygitbook-bot
authored andcommitted
GitBook: [master] one page modified
1 parent ec42715 commit 35b05f4

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ app.Get("/", func(c *fiber.Ctx) {
7373
})
7474
```
7575

76-
**Route with parameter**
76+
**Parameters**
7777

7878
```go
7979
// GET http://localhost:8080/hello%20world
@@ -84,30 +84,29 @@ app.Get("/:value", func(c *fiber.Ctx) {
8484
})
8585
```
8686

87-
**Route with optional parameter**
87+
**Optional parameter**
8888

8989
```go
90-
// GET http://localhost:8080/hello%20world
91-
92-
app.Get("/:value?", func(c *fiber.Ctx) {
93-
if c.Params("value") != "" {
94-
c.Send("Get request with value: " + c.Params("Value"))
95-
// => Get request with value: hello world
96-
return
90+
// GET http://localhost:3000/john
91+
92+
app.Get("/:name?", func(c *fiber.Ctx) {
93+
if c.Params("name") == "" {
94+
c.Send("Hello " + c.Params("name"))
95+
// => Hello john
96+
} else {
97+
c.Send("Where is john?")
9798
}
98-
99-
c.Send("Get request without value")
10099
})
101100
```
102101

103-
**Route with wildcard**
102+
**Wildcards**
104103

105104
```go
106-
// GET http://localhost:8080/api/user/john
105+
// GET http://localhost:3000/api/user/john
107106

108107
app.Get("/api/*", func(c *fiber.Ctx) {
109-
c.Send("API path with wildcard: " + c.Params("*"))
110-
// => API path with wildcard: user/john
108+
c.Send("API path: " + c.Params("*"))
109+
// => API path: user/john
111110
})
112111
```
113112

0 commit comments

Comments
 (0)