Skip to content

Instantly share code, notes, and snippets.

@thomd
Forked from RobinUS2/output-transparent-pixel.go
Created November 26, 2013 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomd/7657446 to your computer and use it in GitHub Desktop.
Save thomd/7657446 to your computer and use it in GitHub Desktop.
import (
"fmt"
"net/http"
"time"
)
const transPixel = "\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"
func pixelHandler(w http.ResponseWriter, r *http.Request) {
// Pixel
w.Header().Set("Content-Type", "image/gif")
w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
w.Header().Set("Expires", "Wed, 11 Nov 1998 11:11:11 GMT")
w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0")
w.Header().Set("Pragma", "no-cache")
fmt.Fprintf(w, transPixel)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment