Skip to content

Commit b1517e6

Browse files
Fennygitbook-bot
authored andcommitted
GitBook: [master] 3 pages modified
1 parent f975bad commit b1517e6

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

application.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,27 +232,37 @@ Routes an HTTP request, where **METHOD** is the [HTTP method](https://developer.
232232
**Signature**
233233

234234
```go
235-
// All, Get, Put, Post, Head, Patch
236-
// Trace, Delete, Connect, Options
237-
app.Get(path string, handlers ...func(*Ctx))
238-
239-
// Matches any HTTP method
240-
// Matches path starting with prefix
235+
/* These methods support :param & :optional? in path
236+
You are required to pass a path to each method */
237+
app.All(path string, handlers ...func(*Ctx))
238+
app.Get(...
239+
app.Put(...
240+
app.Post(...
241+
app.Head(...
242+
app.Patch(...
243+
app.Trace(...
244+
app.Delete(...
245+
app.Connect(...
246+
app.Options(...
247+
248+
/* Use will only match the prefix of each path
249+
i.e. "/john" will match "/john/doe", "/johnnnn"
250+
Use does not support :param & :optional? in path */
241251
app.Use(handlers ...func(*Ctx))
242252
app.Use(prefix string, handlers ...func(*Ctx))
243253
```
244254

245255
**Example**
246256

247257
```go
248-
app.Use(func(c *fiber.Ctx) {
249-
c.Send(c.Method())
258+
app.Use("/api", func(c *fiber.Ctx) {
259+
c.Set("X-Custom-Header", random.String(32))
250260
c.Next()
251261
})
252-
app.Get("/", func(c *fiber.Ctx) {
262+
app.Get("/api/list", func(c *fiber.Ctx) {
253263
c.Send("I'm a GET request!")
254264
})
255-
app.Post("/", func(c *fiber.Ctx) {
265+
app.Post("/api/register", func(c *fiber.Ctx) {
256266
c.Send("I'm a POST request!")
257267
})
258268
```

0 commit comments

Comments
 (0)