File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11module main
22
3- require github.com/gofiber/fiber v1.8.431
3+ require github.com/gofiber/fiber v1.8.431
Original file line number Diff line number Diff line change 11package main
22
33import (
4- "strings"
5-
64 "github.com/gofiber/fiber"
75)
86
9- const pathUser = "/user/"
10-
117func main () {
128 app := fiber .New (& fiber.Settings {
139 Prefork : true ,
1410 CaseSensitive : true ,
1511 StrictRouting : true ,
1612 })
17- app .Use (func (c * fiber.Ctx ) {
18- if strings .HasPrefix (c .Path (), pathUser ) {
19- c .SendString (c .Path ()[6 :])
20- }
13+ app .Get ("/" , func (c * fiber.Ctx ) {
14+ c .SendString ("" )
2115 })
16+ app .Get ("/user/:id" , func (c * fiber.Ctx ) {
17+ c .SendString (c .Params ("id" ))
18+ })
19+ // app.Get("/user/1", func(c *fiber.Ctx) {
20+ // c.JSON("")
21+ // })
22+ // app.Post("/user", func(c *fiber.Ctx) {
23+ // c.JSON("")
24+ // })
25+ // app.Put("/user/1", func(c *fiber.Ctx) {
26+ // c.JSON("")
27+ // })
28+ // app.Patch("/user/1", func(c *fiber.Ctx) {
29+ // c.JSON("")
30+ // })
31+ // app.Delete("/user/1", func(c *fiber.Ctx) {
32+ // c.JSON("")
33+ // })
34+
2235 app .Listen (3000 )
2336}
You can’t perform that action at this time.
0 commit comments