Hertz (CloudWeGo) Go
Hertz (CloudWeGo) için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir Go örneği.
Hertz (CloudWeGo) Go
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()
}
Bu örneği çalıştırıp döndürdüğü baytları karşılaştırdık.
Kontrol et
curl -sI http://localhost:8080/pixel.gif