️ Express inspired web framework written in Go
Go to file
Fenny 3cca2989f1 Update benchmark results 2020-01-27 12:06:49 -05:00
docs Update benchmark results 2020-01-27 12:06:49 -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 Update middleware demo 2020-01-21 00:59:01 +01:00
application.go Add Format function 2020-01-22 12:08:14 +01:00
context.go v1.0.2 2020-01-22 05:42:37 +01:00
go.mod Update go.mod 2020-01-17 22:46:27 +01:00
go.sum v1.0.1-beta 2020-01-21 08:58:11 +01:00
listen.go v1.0.2 2020-01-22 05:42:37 +01:00
methods.go v1.0.2 2020-01-22 05:42:37 +01:00
request.go v1.0.2 2020-01-22 05:42:37 +01:00
response.go Add Format function 2020-01-22 12:08:14 +01:00
router.go v1.0.2 2020-01-22 05:42:37 +01:00
static.go v1.0.2 2020-01-22 05:42:37 +01:00
status.go v1.0.2 2020-01-22 05:42:37 +01:00
utils.go v1.0.2 2020-01-22 05:42:37 +01: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

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!