Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Fiber web framework written in Go 🎉
Siddhesh Khandagale
Siddhesh Khandagale

Posted on

     

Fiber web framework written in Go 🎉

Introduction :

Hey there 👋, today we are going to start with a very young and exciting Fiber Web Framework that is written in Golang. It is a great tool for creating Rapid Web Applications.

Useful Information 💯:

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

It was created with the idea of minimalism to more easily start creating a web application's backend for experienced as well as new gophers.

For more detailed information you just needofficial documentation 🙂

Getting Started 💻:

Image description

Let's start the implementation using Fiber. First of all, you need to installFiber.

Initializing :

Before that make a repository for eg.go-fiber-series , Now initialize a mod file.(If you publish a module, this must be a path from which your module can be downloaded by Go tools. That would be your code's repository.)

go mod init github.com/Siddheshk02
Enter fullscreen modeExit fullscreen mode

InsteadSiddheshk02 use the directory name inside which all the project repos are.

Now, for installing fiber run the following command 🚀:

go get github.com/gofiber/fiber/v2
Enter fullscreen modeExit fullscreen mode

Make a new file main.go in the same folder. Now we'll just try a simple program using Fiber Framework 🚀

Write the following code in themain.go file(It is better to write/Type instead of just copy-pasting)🙂

package mainimport (    "github.com/gofiber/fiber/v2")func main() {    app := fiber.New()    app.Get("/", func(c *fiber.Ctx) error {        return c.SendString("Hello World!!, This is Go-Fiber Tutorial Series")    })    app.Listen(":8080")}
Enter fullscreen modeExit fullscreen mode

Now, let's understand what this code means :)

app is an instance of Fiber, fiber.New() creates a new instance.

app.Method(path string, ...func(*fiber.Ctx) error) This is how the route is defined in fiber.

Method is an HTTP Request Method :GET,PUT,POST, etc.

path is a virtual path on the server.

func(*fiber.Ctx) error is a callback function containing the context executed when the route is matched.

return c.SendString(" ") send the message with the Request.

Here the message is :"Hello World!!, This is Go-Fiber Tutorial Series"

app.Listen() starts the server at the given port.

Now, run the main.go file. For that run the commandgo run main.go .

Output ✨🚀:

Image description

After running the main.go the output will look like the above-given image.

When you follow the given link i.e.http://127.0.0.1:8080 the message will be displayed 🙂

Image description

You can find the complete repository for this tutorial here 👉Github

Conclusion 💯:

I hope you must have got a basic understanding of the fiber web framework and how to get started with it through this tutorial.

In the next upcoming tutorial, you will learn some advanced topics and concepts of the young Fiber Web Framework along with building some crazy stuff 🎉

To get more information about Golang concepts, projects, etc. and to stay updated on the Tutorials do followSiddhesh on Twitter andGitHub.

Until thenKeep Learning, Keep Building 🚀🚀

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Backend Developer specialized in Web Apps, CLI tools, and AI integration with Golang.
  • Pronouns
    He/Him
  • Work
    Freelance Developer
  • Joined

More fromSiddhesh Khandagale

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp