HTTP Methods
Routes an HTTP request, where METHOD is the HTTP method of the request.
- // HTTP methods support :param, :optional? and *wildcards
- // You are required to pass a path to each method
- app.All(path string, handlers ...func(*Ctx)) *Fiber
- app.Get
- app.Put
- app.Post
- app.Head
- app.Patch
- app.Trace
- app.Delete
- app.Connect
- app.Options
- // Use() will only match the beggining of each path
- // i.e. "/john" will match "/john/doe", "/johnnnn"
- // Use() does not support :param & :optional? in path
- app.Use(handlers ...func(*Ctx))
- app.Use(prefix string, handlers ...func(*Ctx)) *Fiber
- app.Use("/api", func(c *fiber.Ctx) {
- c.Set("X-Custom-Header", random.String(32))
- c.Next()
- })
- app.Get("/api/list", func(c *fiber.Ctx) {
- c.Send("I'm a GET request!")
- })
- app.Post("/api/register", func(c *fiber.Ctx) {
- c.Send("I'm a POST request!")
- })