emptygif
Basa: Basa Jawa

Kabeh basa lan framework

Echo Go

Snippet Go kanggo Echo sing mangsuli request menyang /pixel.gif nganggo empty GIF, sing didekode sepisan nalika startup.

Echo Go

Instal
go get github.com/labstack/echo/v5
File
main.go
Lakokake
go run .
package main

import (
	"encoding/base64"
	"log"
	"net/http"

	"github.com/labstack/echo/v5"
)

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

func main() {
	e := echo.New()
	e.GET("/pixel.gif", func(c *echo.Context) error {
		c.Response().Header().Set("Cache-Control", "no-store")
		return c.Blob(http.StatusOK, "image/gif", gif)
	})
	if err := e.Start(":8080"); err != nil {
		log.Fatal(err)
	}
}

Snippet iki wis dilakokake lan byte asile wis dibandhingake.

Priksa

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

Situs resmi: Echo

Liyane ing Go