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 में और