Commit 0e4f6c6d authored by gaoshiyao's avatar gaoshiyao

计数过滤

parent 194c7797
...@@ -21,9 +21,12 @@ func CreateProxyHandler() (*ProxyHandler, error) { ...@@ -21,9 +21,12 @@ func CreateProxyHandler() (*ProxyHandler, error) {
handler := new(ProxyHandler) handler := new(ProxyHandler)
fwd, _ := forward.New(forward.PassHostHeader(true)) fwd, _ := forward.New(forward.PassHostHeader(true))
handler.forward = fwd handler.forward = fwd
ch = make(chan bool, 1)
return handler, nil return handler, nil
} }
var ch chan bool
func (handler *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { func (handler *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if err := count(); err != nil { if err := count(); err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
...@@ -75,6 +78,6 @@ func count() error { ...@@ -75,6 +78,6 @@ func count() error {
return err return err
} }
ic, err := redis.Incr(fmt.Sprintf("%s%s", config.ProxyHost, config.ProxyPath)) ic, err := redis.Incr(fmt.Sprintf("%s%s", config.ProxyHost, config.ProxyPath))
fmt.Println(ic) _, err = ic.Result()
return err return err
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment