️ Express inspired web framework written in Go
Go to file
Fenny c195450790
v1.2.1 🎉 107 Stars 🌟
2020-01-30 17:21:38 -05:00
docs v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
middleware Update to gofiber 2020-01-16 05:58:23 +01:00
LICENSE Update LICENSE 2020-01-16 10:26:35 +01:00
README.md v1.2.1 🎉 107 Stars 🌟 2020-01-30 17:21:38 -05:00
application.go v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
context.go v1.1.0 🎉 100 Stars 🌟 2020-01-28 14:28:09 -05:00
go.mod v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
go.sum v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
listen.go v1.0.2 2020-01-22 05:42:37 +01:00
methods.go v1.1.0 🎉 100 Stars 🌟 2020-01-28 14:28:09 -05:00
request.go v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
response.go v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
router.go v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
static.go v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
status.go v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
types.go v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00
utils.go v1.2.1 🎉 107 Stars 🌟 2020-01-30 23:17:25 -05:00

README.md

Fiber

Fiber is an Express styled HTTP framework implementation running on Fasthttp, the fastest HTTP engine for Go. The package make use of similar framework convention as they are in express. People switching from Node to Go often end up in a bad learning curve to start building their webapps, this project is meant to ease things up for fast development, but with zero memory allocation and performance in mind. See API Documentation

Click here to see all benchmark results

Features

  • Optimized for speed and low memory usage.
  • Rapid Server-Side Programming
  • Easy routing with parameters
  • Static files with custom prefix
  • Middleware with Next support
  • Express API endpoints
  • API Documentation

Installing

Assuming youve already installed Go, install the Fiber package by calling the following command:

$ go get -u github.com/gofiber/fiber

Hello world

Embedded below is essentially the simplest Fiber app you can create.

$ create server.go
package main

import "github.com/gofiber/fiber"

func main() {
  app := fiber.New()

  app.Get("/", func(c *fiber.Ctx) {
    c.Send("Hello, World!")
  })

  app.Listen(8080)
}
$ go run server.go

Browse to http://localhost:8080 and you should see Hello, World! on the page.

Static files

To serve static files, use the Static method.

package main

import "github.com/gofiber/fiber"

func main() {
  app := fiber.New()

  app.Static("./public")

  app.Listen(8080)
}

Now, you can load the files that are in the public directory:

http://localhost:8080/hello.html
http://localhost:8080/js/jquery.js
http://localhost:8080/css/style.css

Middleware

Middleware has never been so easy, just like express you call the Next() matching route function!

package main

import "github.com/gofiber/fiber"

func main() {
  app := fiber.New()

  app.Use(func(c *fiber.Ctx) {
    c.Write("Match anything!\n")
    c.Next()
  })
  app.Use("/api", func(c *fiber.Ctx) {
    c.Write("Match starting with /api\n")
    c.Next()
  })
  app.Get("/api/user", func(c *fiber.Ctx) {
    c.Write("Match exact path /api/user\n")
  })


  app.Listen(8080)
}

API Documentation

We created an extended API documentation including examples, click here

License

gofiber/fiber is free and open-source software licensed under the MIT License.

Caught a mistake? Edit this page on GitHub!