emptygif
Language: English

All languages and frameworks

Fiber Go

A Go snippet for Fiber that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Fiber Go

Install
go get github.com/gofiber/fiber/v3
File
main.go
Run
go run .
package main

import (
	"encoding/base64"
	"log"

	"github.com/gofiber/fiber/v3"
)

var gif, _ = base64.StdEncoding.DecodeString("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

func main() {
	app := fiber.New()
	app.Get("/pixel.gif", func(c fiber.Ctx) error {
		c.Set("Cache-Control", "no-store")
		return c.Type("gif").Send(gif)
	})
	log.Fatal(app.Listen(":8080"))
}

We ran this snippet and compared the bytes it returned.

Check it

curl -sI http://localhost:8080/pixel.gif

Official site: Fiber

More in Go