GithubHelp home page GithubHelp logo

mbrukman / fiber Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gofiber/fiber

0.0 1.0 0.0 3.96 MB

๐Ÿš€ Fiber is an Express.js inspired web framework written in Go ๐Ÿฟ๏ธ

Home Page: https://fiber.wiki

License: MIT License

Go 100.00%

fiber's Introduction

๐Ÿš€ Fiber ru ch

GitHub license Join the chat at https://gitter.im/gofiber/community

Fiber logo

Fiber is an Express.js styled HTTP web framework implementation running on Fasthttp, the fastest HTTP engine for Go (Golang). The package make use of similar framework convention as they are in Express.

People switching from Node.js 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.

API Documentation

๐Ÿ“š We created an extended API documentation (including examples), Visit fiber.wiki.

Benchmark

๐Ÿ‘‰ 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
  • Extended documentation

Installing

Assuming youโ€™ve already installed Go 1.11+ ๐Ÿ˜‰

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:

// server.go

package main

import "github.com/gofiber/fiber"

func main() {
  // Create new Fiber instance
  app := fiber.New()

  // Create new route with GET method
  app.Get("/", func(c *fiber.Ctx) {
    c.Send("Hello, World!")
  })

  // Start server on http://localhost:8080
  app.Listen(8080)
}

Go to console and run:

go run server.go

And now, 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() {
  // Create new Fiber instance
  app := fiber.New()

  // Serve all static files on ./public folder
  app.Static("./public")

  // Start server on http://localhost:8080
  app.Listen(8080)
}

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

http://localhost:8080/hello.html
http://localhost:8080/js/script.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() {
  // Create new Fiber instance
  app := fiber.New()

  // Define all used middlewares in Use()

  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")
  })

  // Start server on http://localhost:8080
  app.Listen(8080)
}

Project assistance

If you want to say thank you or/and support active development gofiber/fiber:

  1. Add a GitHub Star to project.
  2. Tweet about project on your Twitter.
  3. Help us to translate this README and API Docs to another language.

Thanks for your support! ๐Ÿ˜˜ Together, we make Fiber.

Stars over time

Stars over time

License

โš ๏ธ Please note: gofiber/fiber is free and open-source software licensed under the MIT License.

fiber's People

Contributors

kataras avatar koddr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.