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

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

Encore.go (raw endpoint) Go

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

Encore.go (raw endpoint) Go

ઇન્સ્ટૉલ
encore app create --example=hello-world
ફાઇલ
pixel.go
ચલાવો
encore run --port 8080
// pixel/pixel.go: a package with an //encore:api endpoint is an Encore service.
package pixel

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

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

// Raw endpoints get the plain http.ResponseWriter.
//
//encore:api public raw method=GET path=/pixel.gif
func Pixel(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Content-Type", "image/gif")
	w.Header().Set("Cache-Control", "no-store")
	w.Write(gif)
}

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

ચકાસો

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

સત્તાવાર સાઇટ: Encore.go (raw endpoint)

Go માં વધુ