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.
ipelosexa
Zeroing in on affordable medication? Find the most competitive [URL=https://bakuchiropractic.com/lasix/ – lasix 40mg[/URL – online.
Having trouble finding budget-friendly, reliable feminine hygiene products? Look no further; isotretinoin offers a wide variety of choices for your needs. Whether you’re in search of sanitary pads, our selection is both high-quality and affordable.
Aches and pains troubling you? Find relief via https://tv-in-pc.com/retin-a/ , a proven treatment for easing inflammation and pain.
Secure the best rate on [URL=https://marcagloballlc.com/drugs/tadalafil/ – tadalafil[/URL – by shopping online.