@@ -73,7 +73,7 @@ app.Get("/", func(c *fiber.Ctx) {
73
73
})
74
74
```
75
75
76
- ** Route with parameter **
76
+ ** Parameters **
77
77
78
78
``` go
79
79
// GET http://localhost:8080/hello%20world
@@ -84,30 +84,29 @@ app.Get("/:value", func(c *fiber.Ctx) {
84
84
})
85
85
```
86
86
87
- ** Route with optional parameter**
87
+ ** Optional parameter**
88
88
89
89
``` 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?" )
97
98
}
98
-
99
- c.Send (" Get request without value" )
100
99
})
101
100
```
102
101
103
- ** Route with wildcard **
102
+ ** Wildcards **
104
103
105
104
``` go
106
- // GET http://localhost:8080 /api/user/john
105
+ // GET http://localhost:3000 /api/user/john
107
106
108
107
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
111
110
})
112
111
```
113
112
0 commit comments