emptygif
ભાષા: ગુજરાતી

બધી ભાષાઓ અને ફ્રેમવર્ક

Hertz (CloudWeGo) Go

Hertz (CloudWeGo) માટે Go સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.

Hertz (CloudWeGo) Go

ઇન્સ્ટૉલ
go get github.com/cloudwego/hertz
ફાઇલ
main.go
ચલાવો
go run .
package main

import (
	"context"
	"encoding/base64"

	"github.com/cloudwego/hertz/pkg/app"
	"github.com/cloudwego/hertz/pkg/app/server"
	"github.com/cloudwego/hertz/pkg/protocol/consts"
)

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

func main() {
	h := server.Default(server.WithHostPorts(":8080"))
	h.GET("/pixel.gif", func(ctx context.Context, c *app.RequestContext) {
		c.Header("Cache-Control", "no-store")
		c.Data(consts.StatusOK, "image/gif", gif)
	})
	h.Spin()
}

અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.

ચકાસો

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

સત્તાવાર સાઇટ: Hertz (CloudWeGo)

Go માં વધુ