Hi everyone and happy new year 🙂
Fiber is one of Go web frameworks that is simple, intuitive and easy to use. There are a lot of features, but it is not fully featured like PHP Laravel.
It is mainly for API but can be used for websites with HTML templates, not just for SPA. To install Fiber just run this command:
go get github.com/gofiber/fiber/v2
This is example of running web server with one http hander:
package main
import "github.com/gofiber/fiber/v2"
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
})
app.Listen(":3000")
}
Line by line: first we say the name of current package. After that it includes Fiber itself. The main function in main.go file is the point where our program will start. Making instance of Fiber is easy, just call fiber.New(). This method can receive some params, but will cover them in another article.
The simplest way to declare a http handler is to call app.Get, for GET requests. Every handler returns an error and receive as param the Fiber context, where we can use response and request.
The server itself is running with app.Listen method. This is the easiest way to run production ready web server in Go Fiber.
Another features of Fiber are:
- Routes
- Grouping Routes
- Templates
- Error handling
- Validation
- Hooks
- Middlewares
- And many methods to works with request and response and modify headers.
ocumoepuil
Zealously seeking relief from seasonal allergies? Acquire your relief with [URL=https://bluemooncafedothan.com/lasix/ – lasix.com lowest price[/URL – , the trusted solution for fighting allergy symptoms.
Visit our website to uncover the priligy 90 from canada , offering you a cost-effective option for managing your cholesterol levels.
Looking to maintain your hair’s health? Consider https://sci-ed.org/panmycin/ as your go-to option. This effective solution is readily available for those seeking to combat hair loss problems efficiently and conveniently through an online platform.
Discover the benefits of [URL=https://tv-in-pc.com/pill/retin-a-online-no-script/ – retin a[/URL – for heart health and stroke prevention. Purchase your crucial pharmaceutical online today and experience its protective effects.