Patrick Peng Sun 8 лет назад
Родитель
Сommit
7cc6c88f76
2 измененных файлов: 13 добавлений и 1 удалений
  1. +3
    -1
      crmpixel.go
  2. +10
    -0
      server.go

+ 3
- 1
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)


+ 10
- 0
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
}

Загрузка…
Отмена
Сохранить