From 7cc6c88f76f4978a21edfdf277c09ae72b2f00ff Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Sun, 9 Jul 2017 21:07:25 +1000 Subject: [PATCH] test url with abc --- crmpixel.go | 4 +++- server.go | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crmpixel.go b/crmpixel.go index 4dbf16e..0e3dbbe 100644 --- a/crmpixel.go +++ b/crmpixel.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "log" "math/rand" "net/http" "net/url" @@ -20,7 +21,8 @@ func crmpixelImage() (pixel []byte, err error) { } func crmpixel(w http.ResponseWriter, r *http.Request) { - + //log.Println("a") + log.Println(getHTTPRequestQuery(r, "abc")) cookie := crmpixelCookie(r) http.SetCookie(w, &cookie) diff --git a/server.go b/server.go index f453d88..a07977d 100644 --- a/server.go +++ b/server.go @@ -310,3 +310,13 @@ func response404Handler(w http.ResponseWriter) { w.WriteHeader(http.StatusNotFound) fmt.Fprintf(w, "not found") } + +func getHTTPRequestQuery(r *http.Request, name string) (value string) { + rq := r.URL.RawQuery + m, _ := url.ParseQuery(rq) + v, ok := m[name] + if ok { + value = v[0] + } + return +}