mirror of https://github.com/gofiber/fiber.git
Update examples
parent
a2f45a3559
commit
563907cacb
|
@ -144,39 +144,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -162,39 +162,39 @@ Fiber هو **مستوحى** من Express, إطار الويب الأكثر شع
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -144,39 +144,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -144,39 +144,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -144,39 +144,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -195,39 +195,39 @@ Fiber נוצרה **בהשראת** Express, ה-web framework הפופולרית
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -146,39 +146,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -147,39 +147,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -149,39 +149,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -148,39 +148,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -144,39 +144,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -146,39 +146,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -142,39 +142,39 @@ Aşağıda yaygın örneklerden bazıları listelenmiştir. Daha fazla kod örne
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -147,39 +147,39 @@ Listed below are some of the common examples. If you want to see more code examp
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -146,39 +146,39 @@ Fiber **受到** 網路上最流行的Web框架ExpressJS**啟發**,結合Expre
|
|||
|
||||
```go
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app := fiber.New()
|
||||
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
// GET /john
|
||||
app.Get("/:name", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("Hello, %s 👋!", c.Params("name"))
|
||||
c.Send(msg) // => Hello john 👋!
|
||||
})
|
||||
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
// GET /john/75
|
||||
app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("👴 %s is %s years old", c.Params("name"), c.Params("age"))
|
||||
c.Send(msg) // => 👴 john is 75 years old
|
||||
})
|
||||
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
// GET /dictionary.txt
|
||||
app.Get("/:file.:ext", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext"))
|
||||
c.Send(msg) // => 📃 dictionary.txt
|
||||
})
|
||||
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
// GET /flights/LAX-SFO
|
||||
app.Get("/flights/:from-:to", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("💸 From: %s, To: %s", c.Params("from"), c.Params("to"))
|
||||
c.Send(msg) // => 💸 From: LAX, To: SFO
|
||||
})
|
||||
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
// GET /api/register
|
||||
app.Get("/api/*", func(c *fiber.Ctx) {
|
||||
msg := fmt.Sprintf("✋ %s", c.Params("*"))
|
||||
c.Send(msg) // => ✋ /api/register
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
app.Listen(3000)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
package middleware
|
Loading…
Reference in New Issue