return 1x1 transparent GIF in collect request

This commit is contained in:
Danny van Kooten 2016-12-08 12:10:13 +01:00
parent bae8615cf5
commit 87363cce67
2 changed files with 6 additions and 2 deletions

View File

@ -5,7 +5,6 @@ This is a general draft document for thoughts and todo's, without any structure
### What's cooking? ### What's cooking?
- Return 0px GIF in /collect endpoint
- Hand out unique ID to each visitor - Hand out unique ID to each visitor
- Reference site URL when tracking. - Reference site URL when tracking.
- Reference path & title when tracking (indexed by path, update title when changes) - Reference path & title when tracking (indexed by path, update title when changes)

View File

@ -6,6 +6,7 @@ import (
"github.com/mssola/user_agent" "github.com/mssola/user_agent"
"github.com/dannyvankooten/ana/models" "github.com/dannyvankooten/ana/models"
"github.com/dannyvankooten/ana/db" "github.com/dannyvankooten/ana/db"
"encoding/base64"
) )
func CollectHandler(w http.ResponseWriter, r *http.Request) { func CollectHandler(w http.ResponseWriter, r *http.Request) {
@ -74,5 +75,9 @@ func CollectHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Expires", "Mon, 01 Jan 1990 00:00:00 GMT") w.Header().Set("Expires", "Mon, 01 Jan 1990 00:00:00 GMT")
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache") w.Header().Set("Pragma", "no-cache")
w.Header().Set("Status", "200") w.WriteHeader(http.StatusOK)
// 1x1 px transparent GIF
b, _ := base64.StdEncoding.DecodeString("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")
w.Write(b)
} }